-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
53 lines (51 loc) · 1.61 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
const webpack = require("webpack");
const path = require("path");
const resolve = dir => path.join(__dirname, dir);
const BASEURL = process.env.BASE_URL;
module.exports = {
publicPath: "/",
outputDir: "dist",
devServer: {
// open: true, //浏览器自动打开页面
// port: 8009,
proxy: {
"/api": {
//代理api
target: BASEURL, //服务器api地址
changeOrigin: true, //是否跨域
ws: true, //websocket支持
pathRewrite: {
// 重写路径
"^/api": "",
},
},
},
},
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
localStorage: ["mp-storage", "localStorage"],
"window.localStorage": ["mp-storage", "localStorage"],
}),
],
},
chainWebpack: config => {
config.optimization.minimizer("terser").tap(args => {
const compress = args[0].terserOptions.compress;
// 非 App 平台移除 console 代码(包含所有 console 方法,如 log,debug,info...)
compress.drop_console = true;
compress.pure_funcs = [
"__f__", // App 平台 vue 移除日志代码
// 'console.debug' // 可移除指定的 console 方法
];
return args;
});
config.resolve.alias
.set("@", resolve("src"))
.set("@com", resolve("src/components"))
.set("@pages", resolve("src/pages"))
.set("@static", resolve("src/static"))
.set("@service", resolve("src/service"));
},
transpileDependencies: ["uview-ui"],
};