-
Notifications
You must be signed in to change notification settings - Fork 3
/
vue.config.js
95 lines (89 loc) · 3.24 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
'use strict';
const defaultSettings = require('./src/settings.js');
// Node.js path 模块提供用于处理文件路径的小工具
const path = require('path');
function resolve(dir) {
// Node.js 中,__dirname 总是指向被执行 js 文件(当前js文件)的绝对路径
// 连接路径
return path.join(__dirname, dir);
}
const name = defaultSettings.title; // page title
// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run
// You can change the port by the following methods:
// port = 9528 npm run dev OR npm run dev --port = 9528
const port = process.env.VUE_APP_PORT || 9527; // dev port
// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {
/**
* You will need to set publicPath if you plan to deploy your site under a sub path,
* for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
* then publicPath should be set to "/bar/".
* In most cases please use '/' !!!
* Detail: https://cli.vuejs.org/config/#publicpath
*/
publicPath: '/',
outputDir: 'dist', // build 输出路径
assetsDir: 'static', // 静态资源路径
lintOnSave: process.env.NODE_ENV === 'development', // 开发环境下通过 eslint-loader 在每次保存时 lint 代码。这个值会在 @vue/cli-plugin-eslint 被安装之后生效。
productionSourceMap: false, // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
devServer: {
port: port,
open: true,
overlay: {
warnings: false,
errors: true
},
proxy: {
'/dev-api': {
// 此处的写法,目的是为了 将 /dev-api 替换成 https://www.baidu.com/
target: 'http://127.0.0.1:11010/',
// 允许跨域
changeOrigin: true,
ws: true,
pathRewrite: {
'^/dev-api': ''
}
},
'/prod-api': {
// 此处的写法,目的是为了 将 /api 替换成 https://www.baidu.com/
target: 'http://192.168.0.72:8051/',
// 允许跨域
changeOrigin: true,
ws: true,
pathRewrite: {
'^/prod-api': ''
}
}
}
},
configureWebpack: {
// provide the app's title in webpack's name field, so that
// it can be accessed in index.html to inject the correct title.
name: name,
resolve: {
alias: {
'@': require('path').join(__dirname, 'src')
}
}
},
chainWebpack(config) {
// set svg-sprite-loader
config.module
.rule('svg')
.exclude.add(resolve('src/icons'))
.end()
config.module
.rule('icons')
.test(/\.svg$/)
.include.add(resolve('src/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
})
.end()
}
};