You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Vite: classes are detected from the whole project instead of the cssEntryFile directory (differs from Metro) #747
On Vite, Tailwind generates classes found anywhere in the project, not only in the directory of cssEntryFile.
On Metro, compileTailwind.ts#L16-L25 scans **/* from path.dirname(cssPath), which matches the behaviour described in #133 (cssEntryFile marks the app root, and @source adds anything outside it). On Vite, uniwind leaves compilation to @tailwindcss/vite, which scans from the Vite root. The same CSS entry therefore produces different stylesheets on the two bundlers.
In our app (cssEntryFile: './src/global.css') the Vite stylesheet had 182 more rules than the Metro web export, about 2.8 KB gzipped. They came from Markdown docs, SVGs and previous build output in the project root. We excluded them with @source not rules. @import 'tailwindcss' source('./') would be the direct fix, but uniwind cannot parse it (separate issue: #746).
Steps to Reproduce
Clone the repository below. It is apps/vite-example plus docs/notes.md, which is outside src/, not imported, and contains className="bg-red-500 animate-spin"
bun install
bun run build
grep -oE '\.(bg-red-500|animate-spin)' dist/assets/*.css prints .animate-spin and .bg-red-500, although neither is used in src/
This is expected behaviour, not something Uniwind controls. On Vite, Tailwind compilation is handled entirely by @tailwindcss/vite, which scans for class candidates from the Vite project root. That's standard Tailwind v4 behaviour, and you'd get the same result without Uniwind. On Vite, cssEntryFile is only used to collect theme variables for the generated uniwind.css. It doesn't affect where Tailwind looks for classes.
This failed before because of #746, which is fixed in #752 and will ship in the next release. Until then, the @source not rules you're already using are a good workaround.
Activity
Brentlok commentedon Oct 26, 2026
This is expected behaviour, not something Uniwind controls. On Vite, Tailwind compilation is handled entirely by
@tailwindcss/vite, which scans for class candidates from the Vite project root. That's standard Tailwind v4 behaviour, and you'd get the same result without Uniwind. On Vite,cssEntryFileis only used to collect theme variables for the generateduniwind.css. It doesn't affect where Tailwind looks for classes.This failed before because of #746, which is fixed in #752 and will ship in the next release. Until then, the
@source notrules you're already using are a good workaround.