-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
79 lines (73 loc) · 2.09 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
72
73
74
75
76
77
78
79
const webpack = require("webpack");
const CompressionPlugin = require("compression-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const StatsPlugin = require("stats-webpack-plugin");
module.exports = {
productionSourceMap: false,
css: {
sourceMap: false,
},
configureWebpack: (config) => {
let proPlugin = [
new CompressionPlugin({
test: /.(js|css|svg|woff|ttf|json|html|otf)$/,
// threshold: 10240,
filename: '[path].gz[query]',
algorithm: 'gzip',
minRatio: 1,
deleteOriginalAssets: false,
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
drop_debugger: true,
drop_console: true,
},
},
sourceMap: false,
parallel: true,
}),
new StatsPlugin("stats.json", {
chunkModules: true,
chunks: true,
assets: false,
modules: true,
children: true,
chunksSort: true,
assetsSort: true,
}),
];
let devPlugin = [new webpack.HotModuleReplacementPlugin()];
if (process.env.NODE_ENV === "test" || process.env.NODE_ENV === "mock") {
// 开发环境
config.plugins = [...config.plugins, ...devPlugin];
config.devServer = { https: true };
config.devServer.proxy =
process.env.NODE_ENV === "test"
? {
"/api": {
/*if 原来 "https://acmwhut.com/" */
/*if 张志伟的服务器 "http://120.77.181.57:5000/" */
target: "http://dev.acmwhut.com/api/",
changeOrigin: true,
secure: false,
pathRewrite: {
'^/api': ''
}
},
}
: {
"/api": {
target: "http://dev.acmwhut.com/api/",
changeOrigin: true,
pathRewrite: {
"^/api": "",
},
},
};
} else {
// 生产环境
config.plugins = [...config.plugins, ...proPlugin];
}
},
};