-
Notifications
You must be signed in to change notification settings - Fork 2
/
vue.config.js
36 lines (33 loc) · 1.08 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
const path = require('path')
const resolve = dir => {
return path.join(__dirname, dir)
}
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = ['js', 'css']
const BASE_URL = './'
module.exports = {
publicPath: BASE_URL,
lintOnSave: false,
chainWebpack: config => {
config.resolve.alias
.set('@', resolve('src'))
.set('@c', resolve('src/components'))
.set('@s', resolve('src/static'))
.set('@p', resolve('src/pages'))
},
productionSourceMap: false,
configureWebpack: (config)=>{
if(process.env.NODE_ENV === 'production'){
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true // 去除console
config.plugins.push( // 压缩gzip
new CompressionWebpackPlugin({
filename: '[path].gz[query]', // 提示示compression-webpack-plugin@3.0.0的话asset改为filename
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
)
}
}
}