-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathvue.config.js
More file actions
38 lines (36 loc) · 1.16 KB
/
vue.config.js
File metadata and controls
38 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module.exports = {
// 选项...
// productionSourceMap: false,
pluginOptions: {
UglifyPlugin: {
// 插件可以作为 `options.pluginOptions.foo` 访问这些选项。
}
},
configureWebpack: (config) => {
// 引入uglifyjs-webpack-plugin
let UglifyPlugin = require('uglifyjs-webpack-plugin');
if (process.env.NODE_ENV === 'production') {
// 为生产环境修改配置
config.mode = 'production';
// 将每个依赖包打包成单独的js文件
let optimization = {
minimizer: [new UglifyPlugin({
uglifyOptions: {
warnings: false,
compress: {
drop_console: true,
drop_debugger: false,
pure_funcs: ['console.log']
}
}
})]
};
Object.assign(config, {
optimization
})
} else {
// 为开发环境修改配置
config.mode = 'development'
}
}
};