-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvue.config.js
62 lines (61 loc) · 1.88 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
const path = require('path');
const { ProvidePlugin } = require('webpack');
const { dllReferencePluginArray, addAssetsPluginArray } = require('./webpack/config');
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/vue2-template/' : '/',
lintOnSave: true,
devServer: {
port: process.env.VUE_APP_PORT,
proxy: {
'/api': {
target: process.env.VUE_APP_TARGET_API, // 代理地址,这里设置的地址会代替axios中设置的baseURL
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
pathRewrite: {
'^/api': '/api',
},
},
'/openapi': {
target: process.env.VUE_APP_TARGET_API,
changeOrigin: true,
pathRewrite: {
'^/openapi': '/openapi',
},
},
},
},
configureWebpack: {
resolve: {
alias: {
'@': path.resolve('src'),
'@components': path.resolve('src/components'),
},
},
plugins: [
// 引入DLL
...addAssetsPluginArray,
...dllReferencePluginArray,
new ProvidePlugin({
_: 'lodash',
$is: [path.resolve(__dirname, './src/utils/is.js'), 'default'],
$validate: [path.resolve(__dirname, './src/utils/validate.js'), 'default'],
$util: [path.resolve(__dirname, './src/utils/index.js'), 'default'],
$auth: [path.resolve(__dirname, './src/utils/auth.js'), 'default'],
}),
],
},
chainWebpack(config) {
// set svg-sprite-loader
config.module.rule('svg').exclude.add(path.resolve('src/assets/icons')).end();
config.module
.rule('icons')
.test(/\.svg$/)
.include.add(path.resolve('src/assets/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]',
})
.end();
},
};