Skip to content

Commit 028b4f2

Browse files
authored
docs: use css-minimizer-webpack-plugin (#624)
1 parent e8a2d5a commit 028b4f2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

README.md

+11-7
Original file line numberDiff line numberDiff 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');
626624
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
627-
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
625+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
628626

629627
module.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

652656
The runtime code detects already added CSS via `<link>` or `<style>` tag.

0 commit comments

Comments
 (0)