File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -616,20 +616,15 @@ module.exports = {
616616
617617### Minimizing For Production
618618
619- To minify the output, use a plugin like [ optimize-css-assets-webpack-plugin] ( https://github.com/NMFR/optimize-css-assets-webpack-plugin ) .
620- Setting ` optimization.minimizer ` overrides the defaults provided by webpack, so make sure to also specify a JS minimizer:
619+ To minify the output, use a plugin like [ css-minimizer-webpack-plugin] ( https://github.com/webpack-contrib/css-minimizer-webpack-plugin ) .
621620
622621** webpack.config.js**
623622
624623``` js
625- const TerserJSPlugin = require (' terser-webpack-plugin' );
626624const MiniCssExtractPlugin = require (' mini-css-extract-plugin' );
627- const OptimizeCSSAssetsPlugin = require (' optimize- css-assets -webpack-plugin' );
625+ const CssMinimizerPlugin = require (' css-minimizer -webpack-plugin' );
628626
629627module .exports = {
630- optimization: {
631- minimizer: [new TerserJSPlugin ({}), new OptimizeCSSAssetsPlugin ({})],
632- },
633628 plugins: [
634629 new MiniCssExtractPlugin ({
635630 filename: ' [name].css' ,
@@ -644,9 +639,18 @@ module.exports = {
644639 },
645640 ],
646641 },
642+ optimization: {
643+ minimizer: [
644+ // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
645+ // `...`
646+ new CssMinimizerPlugin (),
647+ ],
648+ },
647649};
648650```
649651
652+ This will enable CSS optimization only in production mode. If you want to run it also in development set the ` optimization.minimize ` option to true.
653+
650654### Using preloaded or inlined CSS
651655
652656The runtime code detects already added CSS via ` <link> ` or ` <style> ` tag.
You can’t perform that action at this time.
0 commit comments