forked from IvanZoeng/ant-design-vue-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
31 lines (31 loc) · 810 Bytes
/
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
module.exports = {
css: {
loaderOptions: {
less: {
javascriptEnabled: true
}
}
},
devServer: {
proxy: {
"/api": {
target: "http://localhost:3000",
bypass: function(req, res) {
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}`);
const result = mock(req.method);
delete require.cache[require.resolve(`./mock/${name}`)];
return res.send(result);
}
}
}
}
}
};