Provide a way to prune unused css? #91
Replies: 3 comments 4 replies
-
Yeah it seems like since everything is generated at runtime, it is quite possible to prune the unused properties and not generate classes for them. In my case, I have a Tailwind-like set up (spacing system, color palette, typography styles). I, no joke, can't run a production build (of Next.js) without V8 crashing
I could definitely manually prune this system, but it seems like it is definitely possible for the compiler to do |
Beta Was this translation helpful? Give feedback.
-
The out of memory issues are concerning and might need to be addressed. However, putting that aside I don't think there will be any offical way to prune the atomic CSS from Sprinkles. At least for the time being or until a safe consistent way of doing so is discovered. Vanilla-extract doesn't rely on AST knowledge to work which we see as a big plus and we'd certainly have to give that up to attempt this. Furthermore, we see Sprinkles as a util that provides 80% of your commonly used styles, rather than a huge set of every possible combination. |
Beta Was this translation helpful? Give feedback.
-
Hello guys, just wanted to warn you that someone actually made something to prune unused css, it's finally working. More details here : |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've testing this library in a razzle setup, works pretty well. I loved it.
Following the readme of sprinkles package, I've read that you can use tailwind color values in colorStyles definitions, then I wrote a normalized object of color and provided to
createAtomicStyles
function, see the example below:When I generate the css, vanilla-extract generate all classes to all possible colors in background, color and borderColor with all possible conditions
See:

I think in a production scenario, devs will only create classes to brand related colors, but even though, can be very useful with we can purge some unused rules
(Sorry about the english)
Beta Was this translation helpful? Give feedback.
All reactions