fix(css): resolve app.config.ts source to an absolute path#1404
Merged
Conversation
The `@source "../../app.config.ts"` directive was the only relative path among the CSS sources. Tailwind resolves `@source` relative to the generated CSS file (`<srcDir>/.nuxt/docus.css`), so it pointed at `<rootDir>/app.config.ts` — a file that does not exist. As a result, class names declared in the user's `app.config.ts` (UI theme overrides) were never whitelisted and got purged. Compute an absolute path from `nuxt.options.srcDir` like the other sources so the user's `app.config.ts` is scanned correctly.
commit: |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1403
Resolves #1399
Problem
In
layer/modules/css.ts, the generateddocus.cssdeclared:This was the only relative path among the CSS sources — every other
@source/@importis an absolute filesystem path. Tailwind resolves@sourcerelative to the CSS file that contains it, and that file is generated at<srcDir>/.nuxt/docus.css. So../../app.config.tsresolved to<rootDir>/app.config.ts— a file that does not exist.For example, in this repo the generated
docs/.nuxt/docus.csscontained:The real config lives at
<srcDir>/app.config.ts(e.g.docs/app/app.config.ts). As a result, class names declared in the user'sapp.config.ts(UI theme overrides) were never whitelisted by Tailwind and could get purged.Fix
Compute an absolute path from
nuxt.options.srcDir, consistent with the other sources:This now points at the user's actual
app.config.ts(the samesrcDirtheapp.cssimport is derived from).This may also resolve related class-purging issues seen in nuxt-studio.