-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
48 lines (47 loc) · 1.44 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
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
module.exports = {
devServer: {
hot: true,
host: 'localhost',
port: 8080,
open: true,
proxy: {
'/v': {
target: "http://localhost:8088",
changeOrigin: true
}
}
},
configureWebpack: {
plugins: [
new BundleAnalyzerPlugin()
]
},
chainWebpack: (config) => {
// prod
config.when(process.env.NODE_ENV === 'production', (config) => {
config.entry('app').clear().add('./src/main.js')
// CDN - externals
config.set('externals', {
'vue': 'Vue',
'axios':'axios',
'vue-router': 'VueRouter',
'vue-clipboard2':'VueClipboard'
})
// 首页用isProd来控制html模版,是否加载cdn资源。
config.plugin('html').tap((args) => {
args[0].isProd = true
return args
})
})
// dev
config.when(process.env.NODE_ENV === 'development', (config) => {
config.entry('app').clear().add('./src/main.js')
// 首页自定义isProd
config.plugin('html').tap((args) => {
args[0].isProd = false
return args
})
})
}
}