-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
80 lines (77 loc) · 2.04 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
'use strict'
const titles = require('./title.js')
const glob = require('glob')
const pages = {}
const path = require('path')
glob.sync('./src/pages/**/main.js').forEach(path => {
const chunk = path.split('./src/pages/')[1].split('/main.js')[0]
pages[chunk] = {
entry: path,
template: 'public/index.html',
title: titles[chunk],
chunks: ['chunk-vendors', 'chunk-common', chunk]
}
})
function resolve(dir) {
return path.join(__dirname, dir)
}
// vue.config.js
module.exports = {
pages,
publicPath: './',
devServer: {
open: true, //配置自动启动浏览器
proxy: {
'/guest': {
target: 'http://192.168.100.2:8081',
changeOrigin: true
},
'/home': {
target: 'http://192.168.100.2:8081',
changeOrigin: true
},
'/upload': {
target: 'http://192.168.100.2',
changeOrigin: true
}
}
},
css: {
// 是否开启支持 foo.module.css 样式
modules: false,
// 是否使用 css 分离插件 ExtractTextPlugin,采用独立样式文件载入,不采用 <style> 方式内联至 html 文件中
extract: true,
// 是否构建样式地图,false 将提高构建速度
sourceMap: false,
loaderOptions: {
css: {
// 这里的选项会传递给 css-loader
},
postcss: {
// 这里的选项会传递给 postcss-loader
}
}
},
productionSourceMap: false,
chainWebpack: config => {
config.plugins.delete('named-chunks'), // 超过6个页面build卡着不动,通过禁用named-chunks plugin解决 https://github.com/vuejs/vue-cli/issues/2318
// 'src/static' 目录下为外部库文件,不参与 eslint 检测
config.resolve.alias
.set('@', resolve('src'))
.set('~', resolve('public'))
.set('vue$', 'vue/dist/vue.esm.js')
},
configureWebpack: {
performance: {
hints: false
},
externals: {
'jquery' : '$',
'vue': 'Vue',
'vue-router': 'VueRouter',
'vuex': 'Vuex',
'axios': 'axios',
'element-ui': 'ELEMENT'
}
}
}