-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
41 lines (38 loc) · 1.1 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
const path = require('path');
function resolve(dir) {
return path.join(__dirname, './', dir);
}
module.exports = {
baseUrl: '/',
chainWebpack: config => {
// svg 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/icons'));
config.module.rule('images').test(/\.(png|jpe?g|gif|svg)(\?.*)?$/);
},
devServer: {
open: true,
port: 9523,
proxy: {
'/server': {
target: 'http://jsonplaceholder.typicode.com', //对应自己的接口
changeOrigin: true,
ws: true,
pathRewrite: {
'^/server': ''
}
}
}
}
};