-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvue.config.js
88 lines (88 loc) · 2.59 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const path = require('path')
const CompressionPlugin = require('compression-webpack-plugin')
function resolve (dir) {
return path.join(__dirname, dir)
}
module.exports = {
lintOnSave: false,
productionSourceMap: false,
css: {
loaderOptions: {
less: {
modifyVars: {
'primary-color': '#009688',
'link-color': '#009688',
'body-background': '#f2f2f2',
'modal-body-padding': '12px'
},
javascriptEnabled: true
}
}
},
configureWebpack: {
resolve: {
alias: {
'@': resolve('src')
}
},
plugins: [
new CompressionPlugin({
/* [file]被替换为原始资产文件名。
[path]替换为原始资产的路径。
[dir]替换为原始资产的目录。
[name]被替换为原始资产的文件名。
[ext]替换为原始资产的扩展名。
[query]被查询替换。*/
filename: '[path].gz[query]',
// 压缩算法
algorithm: 'gzip',
// 匹配文件
test: /\.js$|\.css$|\.html$/,
// 压缩超过此大小的文件,以字节为单位
threshold: 10240,
minRatio: 0.8
// 删除原始文件只保留压缩后的文件
// deleteOriginalAssets: true
})
]
},
devServer: {
disableHostCheck: true
},
chainWebpack(config) {
config
.when(process.env.NODE_ENV !== 'development',
config => {
config
.plugin('ScriptExtHtmlWebpackPlugin')
.after('html')
.use('script-ext-html-webpack-plugin', [{
// `runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/
}])
.end()
config
.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial' // only package third parties that are initially dependent
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true
}
}
})
// https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
config.optimization.runtimeChunk('single')
}
)
}
}