-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
64 lines (56 loc) · 1.41 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
const webpack = require("webpack");
const path = require("path");
const CompressionWebpackPlugin = require("compression-webpack-plugin");
let env = process.env.NODE_ENV;
module.exports = {
// 如果是hash模式
publicPath: env !== "development" ? "./" : "/",
// 如果是history模式
// publicPath: env !== "development" ? "/" : "/",
// 静态资源目录 (js, css, img, fonts)
assetsDir: "assets",
//关键点在这 原来的 Compiler 换成了 runtimeCompiler
runtimeCompiler: true,
//设置打包之后是否打包.map文件
productionSourceMap: env !== "development" ? false : true,
// 输出文件目录
outputDir: "dist",
// 让样式找到源
css: {
sourceMap: true
},
devServer: {
port: 8083,
host: "0.0.0.0",
hot: true,
open: false,
disableHostCheck: true,
proxy: {
"/api": {
target: "127.0.0.1", //对应跨域的接口
changeOrigin: true,
ws: false,
pathRewrite: {
"^/api": ""
}
}
}
},
chainWebpack: config => {
config.resolve.alias.set("@", path.resolve(__dirname, "./src"));
},
configureWebpack: config => {
if (env !== "development") {
// 配置打包 压缩js
config.plugins.push(
new CompressionWebpackPlugin({
algorithm: "gzip",
test: /\.js$|\.html$|.\css/, //匹配文件名
threshold: 10240, //对超过10k的数据压缩
deleteOriginalAssets: false, //不删除源文件
minRatio: 0.8
})
);
}
}
};