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

Combine with purgecss #28

Open
technic opened this issue May 31, 2020 · 3 comments
Open

Combine with purgecss #28

technic opened this issue May 31, 2020 · 3 comments

Comments

@technic
Copy link

technic commented May 31, 2020

Hi,

Thanks a lot for this cool plugin!

I am trying to understand what is the order of css plugins and how to customize it. What I want to achieve is to apply fontmin after purgecss. (https://purgecss.com/plugins/webpack.html)

I use font-awesome, and import it to css. The webpack outputs very small and lightweight css file, where only few icons are present.
However fontmin still includes all icons in the font. After small debugging I put the following line in the source code

console.log(item.asset.source())

What I see is that the source code that fontmin sees the unporcessed css file, it is minified but not purged. And includes all icons.
If I replace my original css file with the postporcess one, which has only limited number of icons, then fontmin works as expected and cuts the web font files significanlty.

@patrickhulce
Copy link
Owner

patrickhulce commented May 31, 2020

Thanks for filing @technic! The success of this depends a lot on how the CSS removal plugin works and at what stages specifically it replaces the webpack asset so that fontmin-webpack can see the minified version.

I originally wrote nukecss-webpack for this purpose so I could control it carefully.

It looks like purgecss runs its hook at the compilation stage while fontmin works at thisCompilation stage (which happens before compilation. Admittedly it's been a long time since I wrote this particular piece, so if there's a strong argument for moving our phase to compilation instead, I'm open to it if it's coupled with strong tests.

@technic
Copy link
Author

technic commented May 31, 2020

Hi, great. Thanks for quick answer.
changing to compilation stage fixed my use case.
I can try to help on tests, however I am new to webpack. Which tests are you thinking of?

@patrickhulce
Copy link
Owner

Mainly just ensuring all the existing tests continue to work as expected and add one for purgecss plugin with a parallel config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants