-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
41 lines (40 loc) · 1.15 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')
module.exports = {
css: {
loaderOptions: {
less: {
javascriptEnabled: true
}
}
},
configureWebpack: {
resolve: {
alias: {
'@': path.resolve('src'),
'styles': path.resolve('src/assets/styles'),
'common': path.resolve('src/common'),
}
}
},
devServer: {
proxy: {
'/api': {
target: process.env.MOCK !== "none" ? 'http://localhost:8080' : 'http://193.112.151.166:8080',
// target: 'http://193.112.151.166:8080',
bypass: function(req, res) {
if (req.headers.accept.indexOf('html') !== -1) {
return '/index.html';
} else if (process.env.MOCK !== "none" && req.path.indexOf('api') && req.path.split) {
// eslint-disable-next-line no-console
console.log(req.path)
const name = req.path.split('/api/')[1].split('/').join('_')
const mock = require(`./mock/${name}`);
const result = mock(req.method);
delete require.cache[require.resolve(`./mock/${name}`)];
return res.send(result);
}
}
}
}
}
}