Purgecss: Output unused css

Created on 28 Aug 2018  ·  17Comments  ·  Source: FullHuman/purgecss

Is your feature request related to a problem? Please describe.
Yes, I want to create SSR html file with inline purged CSS but afterwards lazily load leftovers of css

Describe the solution you'd like
I want purgecss to output css that was excluded from output file ( original css without purged css)

Describe alternatives you've considered
Find a multi platform reverse diff solution, but haven't found one

Feature request help wanted

Most helpful comment

the option rejected: true only tells purgecss to collect all the rejected selectors, its only available if you use the node API. The gulp plugin and the CLI don't yet have the feature to output the rejected selectors. We will try to get to it but if you feel like creating a PR, that would be very helpful.

All 17 comments

I was rethinking the whole idea. If you can get an array of classnames which was rejected.

Maybe if there would be some kind of configuration like 'ignore: [array]' so scanned classes would be automatically ignored and not included in purged file

I think both options would be a good Idea, one would be to take all the css that gets purged and optionally output a seperate css file with all of those.

Your second suggestion would be to "blacklist" some styles so that they get purged even if the extractor finds something that would match it right?
I think the name "blacklist" would be good because we already have a options called "whitelist".

I approve this request.
PurgeCSS is awesome to limit the size of the final files but telling us wich selectors have been purged would be a really interesting info to clean stylesheets.
I use webpack to launch PurgeCSS and a simple output in the terminal during the build could be a good start !

I would really like this feature too, but for the purpose of cleaning up the original scss files. Output to the terminal or a file would allow me to delete classes or add to a whitelist until there was nothing left to be purged.

+1

There already is the rejected option (https://www.purgecss.com/configuration) which seems to do this. But it doesn't work with the webpack plugin afaik.

Same here with Gulp. Don't know what should I do after setting rejected: true 🤷‍♂️

Same here, rejected: true does nothing using CLI with a config file. 😞

the option rejected: true only tells purgecss to collect all the rejected selectors, its only available if you use the node API. The gulp plugin and the CLI don't yet have the feature to output the rejected selectors. We will try to get to it but if you feel like creating a PR, that would be very helpful.

I would also like to see this, the unused CSS output to another file. Is that feature available yet? Last update here was almost a year ago. What does it mean this is available in the node API. How do I use that? I am using Gulp. Thank you

+1

+1 for gulp please

+1

+1

+1

+1 .. this sounds essential to be fully aware that the selectors removed are not needed.

I need it to be sure I have whitelisted needed classes and it would be good to have a reference to go back and remove my own unused css directly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simplenotezy picture simplenotezy  ·  3Comments

maartenvanbenthem picture maartenvanbenthem  ·  4Comments

claudiodekker picture claudiodekker  ·  4Comments

spaceemotion picture spaceemotion  ·  4Comments

eldiegod picture eldiegod  ·  4Comments