-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvue.config.js
More file actions
52 lines (50 loc) · 1.7 KB
/
vue.config.js
File metadata and controls
52 lines (50 loc) · 1.7 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const webpack = require('webpack')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
module.exports = {
publicPath: './',
productionSourceMap: false,
devServer: {
open: true,
port: 8888
},
configureWebpack: {
plugins: [
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment$/
}),
new CompressionWebpackPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: /\.(js|css)(\?.*)?$/i,
threshold: 10240, // 对超过10k的数据进行压缩
minRatio: 0.8, // 只有压缩率小于这个值的资源才会被处理
deleteOriginalAssets: false, // 删除原文件
}),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 5,
})
],
optimization: {
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
minSize: 10000,
cacheGroups: {
vendors: {
name(module) {
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1]
return `npm.${packageName.replace('@', '')}`
},
test: /[\\/]node_modules[\\/]/,
priority: -10,
chunks: 'initial'
}
}
},
runtimeChunk: {
name: entrypoint => `runtime-${entrypoint.name}`
}
}
},
}