[v4] Unused variables and classes in the output when using Vite #16535
Replies: 5 comments 2 replies
-
When using You may be able to switch to the file-based scanning in Vite once #16425 is in. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick response, that's what I concluded as well, since I excluded all files, and it still managed to include them. I didn't search through the PRs, I just looked at the open issues. |
Beta Was this translation helpful? Give feedback.
-
PurgeCSS actually solves the problem, so it's not a big issue, but it's still strange behavior. |
Beta Was this translation helpful? Give feedback.
-
Try |
Beta Was this translation helpful? Give feedback.
-
Hey! We are working on purging unused variables (actually had this rolled out already for a patch release but had to revert due to compatibility issues that we need to fix first). I also understand your frustration with the unexpected class names being added, however based on our testing that should be a minimum and likely yield the same results that Tailwind CSS file-based routing would enable. If you could share a quick repro that could help here so we can improve our heuristics? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I came across a question on StackOverflow that I didn’t understand at first, as I had a similar issue up until v4.0.4 with CLI and PostCSS, but v4.0.5 fixed it, and I verified that it works in v4.0.6 as well.
However, when I create a new Vite project, for example, with Svelte or Vue, the build results include unused variables and classes, so in a simple empty project, I get a 22.53kb result instead of the expected file size, which is the Preflight (4kb?).
The
.gitignore
by default excludes the mapping of node_modules, so I assume TailwindCSS doesn't pull variables from there. There isn't a single TailwindCSS class used in the project, and still, a lot of unnecessary content is getting intodist/css/index.css
.The problem is, of course, resolved with PurgeCSS, but the real question is why unused variables (e.g., all colors, ...) and class names (e.g.,
.shadow, .capitalize, .lowercase
) are included in the output by default.Versions
Reproduction steps
pnpm build
Beta Was this translation helpful? Give feedback.
All reactions