Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

打包优化 uglifyjs-webpack-plugin 配置 #1488

Merged
merged 2 commits into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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