Skip to content

Commit fd77038

Browse files
Use optimization.minimizer syntax
1 parent 0dbb167 commit fd77038

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,30 @@ module.exports = {
6868

6969
### Minimizing For Production
7070

71-
While webpack 5 is likely to come with a CSS minimizer built-in, with webpack 4 you need to bring your own. To minify the output, use a plugin like [optimize-css-assets-webpack-plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin):
71+
While webpack 5 is likely to come with a CSS minimizer built-in, with webpack 4 you need to bring your own. To minify the output, use a plugin like [optimize-css-assets-webpack-plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin). Setting `optimization.minimizer` overrides the defaults provided by webpack, so make sure to also specify a JS minimizer:
7272

7373
**webpack.config.js**
7474

7575
```js
76+
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
7677
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
7778
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
7879
module.exports = {
80+
optimization: {
81+
minimizer: [
82+
new UglifyJsPlugin({
83+
cache: true,
84+
parallel: true,
85+
sourceMap: true // set to true if you want JS source maps
86+
}),
87+
new OptimizeCSSAssetsPlugin({})
88+
]
89+
},
7990
plugins: [
8091
new MiniCssExtractPlugin({
8192
filename: "[name].css",
8293
chunkFilename: "[id].css"
83-
}),
84-
new OptimizeCssAssetsPlugin()
94+
})
8595
],
8696
module: {
8797
rules: [

0 commit comments

Comments
 (0)