Skip to content

Commit

Permalink
打包优化 uglifyjs-webpack-plugin 配置 (#1488)
Browse files Browse the repository at this point in the history
* 打包优化 uglifyjs-webpack-plugin 配置

去console,压缩,注释

* 打包优化 uglifyjs-webpack-plugin 配置

去console,压缩,注释
  • Loading branch information
Veveue authored and sorrycc committed Nov 21, 2018
1 parent 7ed9241 commit f533192
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
28 changes: 27 additions & 1 deletion docs/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 28 additions & 0 deletions docs/zh/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f533192

Please sign in to comment.