-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvue.config.js
More file actions
36 lines (33 loc) · 1.08 KB
/
vue.config.js
File metadata and controls
36 lines (33 loc) · 1.08 KB
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
module.exports = {
css: {
loaderOptions: {
less: {
javascriptEnabled: true
}
}
},
devServer: {
proxy: {
'/api': {
target: 'http://localhost:8080',
bypass: function (req, res, proxyOptions) {
if (req.headers.accept.indexOf('html') !== -1) {
console.log('Skipping proxy for browser request.');
return '/index.html';
}else if(process.env.MOCK !== "none"){
const name = req.path.split('/api/')[1].split('/').join('_')
const mock = require(`./mock/${name}`)
// /api/dashboard/chart?ID=123456',
// dashboard_chart
// dashboard_chart.js
// D:\vue_study\hello-world\vue.config.js
// D:\vue_study\hello-world\mock\dashboard_chart.js
delete require.cache[require.resolve(`./mock/${name}`)]
const result = mock(req.method)
return res.send(result)
}
},
},
},
},
}