File tree 1 file changed +11
-7
lines changed
1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -616,20 +616,15 @@ module.exports = {
616
616
617
617
### Minimizing For Production
618
618
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 ) .
621
620
622
621
** webpack.config.js**
623
622
624
623
``` js
625
- const TerserJSPlugin = require (' terser-webpack-plugin' );
626
624
const MiniCssExtractPlugin = require (' mini-css-extract-plugin' );
627
- const OptimizeCSSAssetsPlugin = require (' optimize- css-assets -webpack-plugin' );
625
+ const CssMinimizerPlugin = require (' css-minimizer -webpack-plugin' );
628
626
629
627
module .exports = {
630
- optimization: {
631
- minimizer: [new TerserJSPlugin ({}), new OptimizeCSSAssetsPlugin ({})],
632
- },
633
628
plugins: [
634
629
new MiniCssExtractPlugin ({
635
630
filename: ' [name].css' ,
@@ -644,9 +639,18 @@ module.exports = {
644
639
},
645
640
],
646
641
},
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
+ },
647
649
};
648
650
```
649
651
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
+
650
654
### Using preloaded or inlined CSS
651
655
652
656
The runtime code detects already added CSS via ` <link> ` or ` <style> ` tag.
You can’t perform that action at this time.
0 commit comments