diff --git a/docs/config/README.md b/docs/config/README.md index 6aab60a1c2c7..b27044a68dc1 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -182,7 +182,33 @@ chainWebpack(config, { webpack }) { config.plugins.delete('progress'); } ``` - +configure [uglifyjs-webpack-plugin](https://webpack.docschina.org/plugins/uglifyjs-webpack-plugin/) +```js +chainWebpack(config, { webpack }) { + config.merge({ + plugin: { + install: { + plugin: require('uglifyjs-webpack-plugin'), + args: [{ + sourceMap: false, + uglifyOptions: { + compress: { + // remove `console.*` + drop_console: true, + }, + output: { + // whether to actually beautify the output + beautify: false, + // remove all comments + comments: false, + }, + } + }] + } + } + }) +} +``` ### theme The configuration theme is actually equipped with the less variable. Support for both object and string types, the string needs to point to a file that returns the configuration. diff --git a/docs/zh/config/README.md b/docs/zh/config/README.md index 2790abdf09af..91ed2ad7fc1c 100644 --- a/docs/zh/config/README.md +++ b/docs/zh/config/README.md @@ -181,6 +181,34 @@ chainWebpack(config, { webpack }) { // 删除进度条插件 config.plugins.delete('progress'); } +``` +打包优化 [uglifyjs-webpack-plugin](https://webpack.docschina.org/plugins/uglifyjs-webpack-plugin/) 配置 +```js +chainWebpack(config, { webpack }) { + config.merge({ + plugin: { + install: { + plugin: require('uglifyjs-webpack-plugin'), + args: [{ + sourceMap: false, + uglifyOptions: { + compress: { + // 删除所有的 `console` 语句 + drop_console: true, + }, + output: { + // 最紧凑的输出 + beautify: false, + // 删除所有的注释 + comments: false, + }, + } + }] + } + } + }) +} + ``` ### theme