FullHuman / postcss-purgecss

PostCSS plugin for purgecss
MIT License
91 stars 5 forks source link

Process only given entrypoints in webpack #52

Open pavelloz opened 4 years ago

pavelloz commented 4 years ago

Hello,

Im using purgecss (in webpack, via postcss-loader) in a big project that has 3 different layouts: old, transition and new.

Old and transition i would like to keep intact, and new one is using tailwindcss, so obviously i would like to put it through purgecss.

I know i can do two webpack configs, but is it possible to do it natively with postcss-purgecss, or are there any plans in introducing such a feature?

Note: Temporairly ill try to use ignore comments in all the files i want to exclude, but i must say, it would be more convenient to filter them out on a config level. :)

pavelloz commented 4 years ago

I used ignore comments and they work great, but having said that, i cannot put them into dynamically created async chunks, so dependencies pulled straight from node_modules are getting obliterated.

Example:

app.js
import("./markdown_editor"); // creates dynamic chunk in webpack
markdown_editor.js
import "simplemde/dist/simplemde.min.css";

This will spit out dynamic chunk css/vendors~markdown_editor.1dc.css which gets purged and completely useless.

Now i have two paths again: 1) create separate webpack config, as before... and im closer and closer to do that. 2) start whitelisting classes used by those dependencies and pray to everyone (including me) to never forget that

I hope this gives more view into how this feature would help people :)