-
Notifications
You must be signed in to change notification settings - Fork 2
/
vue.config.js
52 lines (50 loc) · 1.62 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
const path = require('path')
const apiRoot = process.env.NODE_ENV === 'development' ? 'http://www.mock.eyesky.site/mock/11' : 'localhost:8900/farm'
console.log(apiRoot)
function resolve (dir) {
return path.join(__dirname, dir)
}
module.exports = {
devServer: {
proxy: {
'/': {
target: apiRoot, // 对应自己的接口 http://www.mock.eyesky.site/mock/11
changeOrigin: true,
ws: false,
pathRewrite: {
'^/farm': ''
}
}
}
},
lintOnSave: true,
chainWebpack: (config) => {
config.resolve.alias
.set('@', resolve('src'))
.set('api', resolve('src/api'))
.set('assets', resolve('src/assets'))
.set('common', resolve('src/common'))
.set('components', resolve('src/components'))
.set('plugins', resolve('src/plugins'))
.set('router', resolve('src/router'))
.set('store', resolve('src/store'))
.set('views', resolve('src/views'))
// svg rule loader
const svgRule = config.module.rule('svg') // 找到svg-loader
svgRule.uses.clear() // 清除已有的loader, 如果不这样做会添加在此loader之后
svgRule.exclude.add(/node_modules/) // 正则匹配排除node_modules目录
svgRule // 添加svg新的loader处理
.test(/\.svg$/)
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
})
// 修改images loader 添加svg处理
const imagesRule = config.module.rule('images')
imagesRule.exclude.add(resolve('src/assets/icon/svg'))
config.module
.rule('images')
.test(/\.(png|jpe?g|gif|svg)(\?.*)?$/)
}
}