-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvue.config.js
46 lines (43 loc) · 1.4 KB
/
vue.config.js
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
39
40
41
42
43
44
45
46
const path = require('path')
const TerserPlugin = require('terser-webpack-plugin')
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin')
module.exports = {
lintOnSave: false,
productionSourceMap: process.env.NODE === 'development' ? true : false,
/** 开启多进程处理 Babel 编译 */
parallel: require('os').cpus().length > 1,
chainWebpack: (config) => {
// with an absolute path, it will only search in the given director.
config.resolve.modules.store = new Set([
path.resolve(__dirname, 'node_modules'),
'node_modules',
])
// high frequency extension, it's best to be at the front of the array
config.resolve.extensions.store = new Set(['.js', '.vue', '.json', '.mjs', '.jsx', '.wasm'])
if (process.env.NODE_ENV === 'development') {
// development
// js is not compressed
config.optimization.minimize(false)
// css is not compressed
config.plugins.delete('optimize-css')
} else {
// production
// clean console.log
config.optimization.minimizer([
new TerserPlugin({
test: /\.js(\?.*)?$/i,
terserOptions: {
compress: {
drop_debugger: true,
drop_console: true,
pure_funcs: ['console.log'],
},
},
}),
])
}
},
configureWebpack: {
plugins: [new HardSourceWebpackPlugin()],
},
}