-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
Issue with PurgeCSS in production mode #337
Comments
Hi @javiereguiluz, I don't know really how that plugin works but I think you may be right about that issue being caused by the removal of comments in production mode... That's part of the minification process which is triggered by the webpack-encore/lib/loaders/css.js Lines 25 to 35 in 2a1a18a
Based on its documentation you can use CSSNano options instead of boolean, so maybe there is a way to minimize CSS files but keep some of the comments. However... Encore doesn't allow to change these options easily yet. You can still do it by modifying the generated Webpack config object manually but that makes the |
Thanks for the detailed answer! I don't know anything about the internals of Encore, but the simplest solution to me would be to be able to control the order in which things are executed. If I could run PurgeCSS plugin before Encore's minify plugins, this problem would be solved. Thanks! |
@javiereguiluz encore does not have a minifying plugin for CSS. The CSS Loader does the minification of CSS. |
@stof as you can see I know nothing about Encore internals 😝 Anyway, can we control the order of things somehow? Thanks! |
@javiereguiluz yo can control orders of plugins (well, partially, as core plugins don't have priorities allowing to hook in the middle unfortunately, defeating the feature). But that won't help you in this case, as minimizing CSS is not performed by a plugin but by the loader itself. And as said by @Lyrkan, configuring the CSS loader is not possible easily currently. It will be solved by #335. For now, it would require transforming the generated config (which is probably a pain for this case) |
@javiereguiluz To extend a bit more on what @stof said:
|
@Lyrkan perfectly explained! Thanks. I wish things worked differently though. For example, instead of minifying CSS contents when loading them, I'd prefer to have a |
Well, as we said, we already have the solution: #335 gives access to configuring the CSS loader, which would allow to configure the options of the minification (allowing to keep comments) |
I also had this issue with webpack, purgecss and rails. My fix was to change the ignore comments to: |
After fixing some errors with PurgeCSS and Encore (#330) now I have another issue.
I use the
/* purgecss ignore */
,/* purgecss start ignore */
and/* purgecss end ignore */
comments to tell PurgeCSS not to delete some styles (I'm aware of thewhitelist
andwhitelistPatterns
options. I use them too, but I can't use them in some cases).When I run
yarn encore dev
everything works but when I runyarn encore production
those styles are not preserved by PurgeCSS. Maybe the reason is that Encore deletes comments inproduction
and therefore PurgeCSS never sees them? If that's true, what can we do to solve this? Thanks!The text was updated successfully, but these errors were encountered: