-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
77 lines (74 loc) · 2.03 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
/*
=============== 注意事项 ===============
1.本项目是多页应用,且路由使用的是historty模式,所以请不要修改publicPath的值
2.nginx配置类似于如下
location /home {
try_files $uri $uri/ /home.html;
root html;
}
*/
'use strict'
const glob = require('glob')
const path = require('path')
let pages = {}
function resolve(dir) {
return path.join(__dirname, dir)
}
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: chunk,
chunks: ['chunk-vendors', 'chunk-common', chunk]
}
})
// 代理函数
const setProxy = table => {
let proxy = {}
for (const [k, v] of table) {
proxy[k] = {
changeOrigin: true,
target: v,
pathRewrite: { [`^${k}`]: '' }
}
}
return proxy
}
module.exports = {
pages,
css: {
loaderOptions: {
// 向所有 Sass 样式传入共享的全局变量
sass: {
prependData: `@import "~styles/variables.scss";`
}
}
},
chainWebpack: config => {
config.resolve.alias
.set('@', resolve('src'))
.set('modules', resolve('src/modules'))
.set('config', resolve('src/config'))
.set('components', resolve('src/components'))
.set('styles', resolve('src/styles'))
.set('utils', resolve('src/utils'))
.set('imgs', resolve('src/assets/imgs'))
.set('pages', resolve('src/pages'))
},
devServer: {
// index: 'index.html',
open: true,
openPage: 'home',
host: '',
port: 9988,
https: false,
hotOnly: false,
proxy: setProxy(
new Map([
['/xin', 'http://172.16.10.153:8762'], // 小鑫
['/dev', 'http://118.25.94.233:8762'] // serve
])
)
}
}