-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
72 lines (65 loc) · 1.75 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
const { wpList } = require('./src/apiConfig.js')
const dayjs = require('dayjs')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
require('events').EventEmitter.defaultMaxListeners = 40
process.env.VUE_APP_buildTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
console.log(process.env.VUE_APP_buildTime)
// 设置代理地址
const setProxy = () => {
const proxy = {}
wpList.map(el => {
const item = {
target: el.url,
secure: false
}
if (el.isRewrite) {
item.pathRewrite = { ['^/' + el.value]: '' }
}
// 设置wp接口代理
proxy['^/' + el.value] = item
// 设置api接口代理
proxy['^/' + el.value + '/api'] = {
target: el.url,
secure: false
}
if (el.activityApi) {
proxy['^/api/activity'] = {
target: el.activityApi,
secure: false
}
}
})
return proxy
}
// 设置插件
const setPlugins = () => {
const plugins = []
// 生产环境插件
if (process.env.NODE_ENV === 'production') {
plugins.push(
// 文件分析报告
new BundleAnalyzerPlugin({
analyzerMode: 'static', // 可选值有server static disabled
generateStatsFile: false,
statsOptions: { source: false },
openAnalyzer: false
})
)
}
return plugins
}
const config = {
lintOnSave: false,
devServer: {
hot: true,
overlay: {
warnings: false,
errors: true
},
proxy: setProxy()
},
configureWebpack: {
plugins: setPlugins()
}
}
module.exports = config