-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
71 lines (68 loc) · 2.05 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
// vue.config.js
const path = require("path");
const AntDesignThemePlugin = require("antd-theme-webpack-plugin");
const webpack = require("webpack");
const options = {
antDir: path.join(__dirname, "./node_modules/ant-design-vue"),
stylesDir: path.join(__dirname, "./src"),
varFile: path.join(
__dirname,
"./node_modules/ant-design-vue/lib/style/themes/default.less"
),
mainLessFile: "",
themeVariables: ["@primary-color"],
generateOnce: false,
lessUrl: "https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.2/less.min.js"
};
const themePlugin = new AntDesignThemePlugin(options);
module.exports = {
css: {
loaderOptions: {
less: {
javascriptEnabled: true,
modifyVars: {
"primary-color": "#1DA57A"
}
}
}
},
configureWebpack: {
plugins: [themePlugin, new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)],
resolve: {
alias: {
"@ant-design/icons/lib/dist$": path.resolve(__dirname, "./src/icons.js")
}
}
},
chainWebpack: config => {
const svgRule = config.module.rule("svg");
// 清除已有的所有 loader。
// 如果你不这样做,接下来的 loader 会附加在该规则现有的 loader 之后。
svgRule.uses.clear();
// 添加要替换的 loader
svgRule.use("vue-svg-loader").loader("vue-svg-loader");
},
devServer: {
proxy: {
"/api": {
target: "http://localhost:8080",
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);
//console.log(result + "" + mock);
delete require.cache[require.resolve(`./mock/${name}`)];
return res.send(result);
}
}
}
}
}
};