Replies: 3 comments 1 reply
-
summoning @adamwathan (sorry!) |
Beta Was this translation helpful? Give feedback.
-
This would be very helpful! |
Beta Was this translation helpful? Give feedback.
-
A version of this feature is in Tailwind v4, from the v4 alpha release blog post:
|
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.
-
From my understanding the way purging currently works is that the script simply scans your
content
directories and only includes classes found in those files (source). Works fine but: Is it possible/would you consider making this process a little more refined and only include classes from files that are actually imported in the project? (as an option maybe)Right now if I have a component that is not used anywhere in the project, its classes will still be included in the generated CSS file.
Ideally that component's classes should be ignored until it's
import
ed somewhere in the dependency graph.The scenario I have in mind for this functionality are component libraries. It would be a nice optimisation to only generate CSS from the components you actually import in your project (instead of adding the
node_modules
path of the library to thecontent
list and generate CSS from every single component in the library)I experimented a little using https://github.com/dependents/node-dependency-tree with this config:
And then in the
tailwind.config.js
I am setting thecontent
value asAnd I got the result I was looking for: unused components' classes are not included in the final CSS file
Beta Was this translation helpful? Give feedback.
All reactions