Skip to content

fix(css): resolve app.config.ts source to an absolute path#1404

Merged
larbish merged 1 commit into
mainfrom
fix/css-app-config-source
Jun 24, 2026
Merged

fix(css): resolve app.config.ts source to an absolute path#1404
larbish merged 1 commit into
mainfrom
fix/css-app-config-source

Conversation

@benjamincanac

@benjamincanac benjamincanac commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Resolves #1403
Resolves #1399

Problem

In layer/modules/css.ts, the generated docus.css declared:

@source "../../app.config.ts";

This was the only relative path among the CSS sources — every other @source/@import is an absolute filesystem path. Tailwind resolves @source relative to the CSS file that contains it, and that file is generated at <srcDir>/.nuxt/docus.css. So ../../app.config.ts resolved to <rootDir>/app.config.ts — a file that does not exist.

For example, in this repo the generated docs/.nuxt/docus.css contained:

@source "/…/docus/docs/content/**/*";
@source "/…/docus/layer/app/**/*";
@source "../../app.config.ts";   ← resolves to //docus/app.config.ts (missing)
@source "/…/docus/layer/modules/assistant/**/*";

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's app.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:

const appConfigPath = resolve(nuxt.options.srcDir, 'app.config.ts')
// …
@source "${appConfigPath.replace(/\\/g, '/')}";

This now points at the user's actual app.config.ts (the same srcDir the app.css import is derived from).

Note: the layer's own app.config.ts (layer/app/app.config.ts) is already covered by the @source "${layerDir}/**/*" glob, so this line only ever needed to target the user's config.

This may also resolve related class-purging issues seen in nuxt-studio.

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.
@pkg-pr-new

pkg-pr-new Bot commented Jun 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/create-docus@1404
npm i https://pkg.pr.new/docus@1404

commit: 248a6c0

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docus Ready Ready Preview Jun 24, 2026 10:36am

@larbish larbish merged commit b2486f4 into main Jun 24, 2026
3 checks passed
@larbish larbish deleted the fix/css-app-config-source branch June 24, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants