FullHuman / purgecss

Remove unused CSS
https://purgecss.com
MIT License
7.77k stars 247 forks source link

Ability to whitelist whole CSS files #919

Open dmt0 opened 2 years ago

dmt0 commented 2 years ago

Is your feature request related to a problem? Please describe. I'm importing an NPM module that includes a CSS file. A lot of the classes in that file are caught by PurgeCSS.

Describe the solution you'd like A configuration option to whitelist entire files by path.

Describe alternatives you've considered

aleesaan commented 2 years ago

I was also looking for this! In my case the issue was that I want to exclude all Datatables (+ plugins) styles from the purging, as it would be impossible to manually find and safelist them one by one.

I also tried wrapping the imports like:

/* purgecss start ignore */
@import "~datatables.net/...";
/* purgecss end ignore */ 

But that also doesn't work 😢 Anybody has suggestions?

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

dmt0 commented 2 years ago

Bump

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

dmt0 commented 1 year ago

I saw no negative feedback, so ... bump 🤷

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

aleesaan commented 1 year ago

Not stale

anoop0567 commented 1 year ago

Hi @dmt0 and @aleesaan , have you any workaround solution for this I'm using next.js module css and don't want to remove them at all.

dmt0 commented 1 year ago

No workarounds so far. This package is unusable to me unfortunately.

anoop0567 commented 1 year ago

No workarounds so far. This package is unusable to me unfortunately.

@dmt0 have you used any other package for the same functionality

aaronhernan commented 1 year ago

I made it work, with Laravel 10 + Vite 4.4 + PurgeCss, with a workaround... First... /* purgecss start ignore */ didnt work at all, so i have to use /*! purgecss start ignore */ Second, it didnt work for me on full @import /*! purgecss start ignore */ @import 'datatables.net-dt/css/jquery.dataTables.css'; ... so... i copied the .css file to my resource dir, and include the start/stop inside the .css file, and then just import it @import 'jquery.dataTables-PurgeIgnored.css'; ...

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

dmt0 commented 8 months ago

bump

ogbotemi-2000 commented 3 months ago

Here is a rather new but, thoroughly tested package that I published in order to do away with the frustrations of PurgeCSS: https://www.npmjs.com/package/rmrf-css It can whitelist CSS files based on the argument you provide via the CLI or its exported function. Please read the README for more info