-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
64 lines (62 loc) · 1.57 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
const webpack = require('webpack')
const CompressionPlugin = require('compression-webpack-plugin')
const BASE_URL = process.env.NODE_ENV === 'production'
? '/'
: '/'
module.exports = {
publicPath: BASE_URL,
chainWebpack: config => {
config.module
.rule('images')
.use('url-loader')
.loader('url-loader')
.tap(options => Object.assign(options, {
limit: 1024 * 10
}))
},
configureWebpack: {
plugins: [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new CompressionPlugin({
algorithm: 'gzip', // 使用gzip压缩
test: /\.js$|\.json$|\.txt$|\.md$|\.html$|\.css$|\.woff2$|\.woff$|\.ttf$|\.otf$|\.svg$/, // 匹配文件名
filename: '[path][base].gz[query]',
minRatio: 1,
threshold: 1024 * 10
})
],
optimization: {
splitChunks: {
chunks: 'all',
maxSize: 1024 * 1500,
minSize: 1024 * 1000,
cacheGroups: {
default: {
name: 'common',
priority: -20
},
vendors: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
priority: -10
}
}
}
},
devtool: process.env.NODE_ENV === 'development' ? 'source-map' : false
},
css: {
extract: false,
sourceMap: process.env.NODE_ENV === 'development'
},
lintOnSave: process.env.NODE_ENV === 'development',
productionSourceMap: false,
devServer: {
disableHostCheck: true,
proxy: {
'/api': {
target: process.env.VUE_APP_PROXY_HOST
}
}
}
}