survivejs / webpack-book

From apprentice to master (CC BY-NC-ND)
https://survivejs.com/webpack/
2.42k stars 319 forks source link

Minifying CSS: explain why OptimizeCSSAssetsPlugin is better than css-loader #283

Closed sapegin closed 4 years ago

sapegin commented 7 years ago

Both are using cssnano, what’s the difference?

bebraw commented 7 years ago

Three things:

sapegin commented 7 years ago

As I understand it minifies the whole file instead of separate chunks which could be potentially faster and with a smaller result.

bebraw commented 7 years ago

Yeah, that's the key point.

bebraw commented 7 years ago

The problem is that I don't know when the CSS workflow is going to change. Maybe in a few months with webpack 4?

sapegin commented 7 years ago

Yeah, CSS in webpack is a big mess now ;-| Trying to make any sense of it again — couldn’t find any tutorial that would suggest using minimize=true for css-loader in production. They either do it unconditionally (not sure it’s a good idea) or still rely on LoaderOptionsPlugin.

bebraw commented 6 years ago

Can you check https://survivejs.com/webpack/optimizing/minifying/#minifying-css and let me know what you think? Is it clear enough?

sapegin commented 6 years ago

This sentence is very obscure:

Out of the available solutions, OptimizeCSSAssetsPlugin composes the best.

bebraw commented 4 years ago

Webpack dropped support for minification from css-loader so the approach that's covered seems like what remains. I rewrote the sentence to explain better.