[v4] Tailwind generates a lot of unused styles #16634
Replies: 7 comments
-
Efforts are underway to clear unused CSS variables and Also, as per #16211 (comment):
|
Beta Was this translation helpful? Give feedback.
-
@wongjn is there a way to control that? I do want to generate all CSS variables with |
Beta Was this translation helpful? Give feedback.
-
Sorry, what are you referring to when you ask if there is any "way to control that"? |
Beta Was this translation helpful? Give feedback.
-
I mean with the work in #16211 and #16403, want to make sure the generating all CSS variables with |
Beta Was this translation helpful? Give feedback.
-
Yes, consider reading the Always including all variables section in #16211 (assuming the same API would be reimplemented). |
Beta Was this translation helpful? Give feedback.
-
Hey! Thanks for the report. Like @wongjn said that's something that's currently on top of our minds as well and re-land a fix for this very soon! |
Beta Was this translation helpful? Give feedback.
-
Not directly related to this discussion, but since I read the thread many times while debugging our issue, I wanted to share a solution in case it helps someone in the future. After migrating to Tailwind v4, our application's reproducibility checks started failing. We tried various solutions, including using Instead of using a plain CSS Hope this helps someone down the road! |
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.
-
Steps to reproduce
@import "tailwindcss";
.npm run build
command.Expected result
The generated CSS file should contain only essential styles, such as CSS resets, with a file size of approximately 2 KB.
Actual result
The generated CSS file includes a significant number of unused styles, with a total size of 21.8 KB.
utilities
styles,@keyframes
rules,@property
rules.Workaround
PurgeCSS can remove most of the unused styles, except for
@property
rules:With this configuration, the final CSS file size is reduced to approximately 4 KB.
Beta Was this translation helpful? Give feedback.
All reactions