Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover deleted code after purge #816

Closed
Quidam74 opened this issue Dec 8, 2021 · 3 comments
Closed

Recover deleted code after purge #816

Quidam74 opened this issue Dec 8, 2021 · 3 comments
Milestone

Comments

@Quidam74
Copy link

Quidam74 commented Dec 8, 2021

Is your feature request related to a problem? Please describe.
I'm curently trying to make some optimisation of LCP and purging seems to be a good solution. But i'll like to go deeper, a lot of my classes are modificator (BEM) and i don't need them before the document ready, so i could load all those classes later, in a splited css file loaded from javascript. I'm using webpack.

Describe the solution you'd like
A good solution for me could be to get the purged css in a separated file, i looked for something like this in documentation but doesn't find it. It could also allow to realy purge your dead code, i mean, purge your source code, not only the compiled one.

Describe alternatives you've considered
An other solution would be to create a new entry point, dedicated to this post-domReady load, but in many way it's a bit too hard for the time i have on this task. (dynamic name in javascrypt, BEM build as autonome component ...)

Additional context
First issue opened on a public repo ! be gentle ;-)
Also i have no knowlenge about creating plugins with webpack, but i'll be happy to contribute, any explaination/ressources would be nice !

ty for reading !

@kevinramharak
Copy link
Contributor

I implemented this feature a few weeks ago, but I don't think I updated the docs (or they need a seperate publish process). See #763.

Usage: purgecss --css <css...> --content <content...> [options]
Remove unused css selectors
Options:
  -V, --version                        output the version number
  -con, --content <files...>           glob of content files
  -css, --css <files...>               glob of css files
  -c, --config <path>                  path to the configuration file
  -o, --output <path>                  file path directory to write purged css files to
  -font, --font-face                   option to remove unused font-faces
  -keyframes, --keyframes              option to remove unused keyframes
  -v, --variables                      option to remove unused variables
  -rejected, --rejected                option to output rejected selectors
  -rejected-css, --rejected-css        option to output rejected css
  -s, --safelist <list...>             list of classes that should not be removed
  -b, --blocklist <list...>            list of selectors that should be removed
  -k, --skippedContentGlobs <list...>  list of glob patterns for folders/files that should not be scanned
  -h, --help                           display help for command

@Ffloriel Do you need to do something seperate to update the documentation website?

@kevinramharak
Copy link
Contributor

Also I havent 'upstreamed' those options to any of the tool plugins yet. For webpack it would have to be implemented here https://github.com/FullHuman/purgecss/tree/main/packages/purgecss-webpack-plugin

@Quidam74
Copy link
Author

Quidam74 commented Dec 9, 2021

Hi ! thank you for your anwser, i'll try to work on this next week ! happy to have this opportunity !

Don't know if it's a good think to close this issue by myself now, feel free to do it !

@Ffloriel Ffloriel added this to the 5.0.0 milestone Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants