-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
57 lines (55 loc) · 1.65 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
const path = require("path");
const CompressionWebpackPlugin = require("compression-webpack-plugin");
function resolve(dir) {
return path.join(__dirname, dir);
}
// dev服务端口
const devServerPort = 4396;
module.exports = {
productionSourceMap: false, // 生产环境关闭sourcemap
publicPath: process.env.NODE_ENV === "production" ? "/vue-admin/" : "/",
devServer: {
port: devServerPort, // 端口
open: false, // 启动时自动打开
progress: true, // 展示进度条
},
pluginOptions: {
"style-resources-loader": {
preProcessor: "scss",
patterns: [path.resolve(__dirname, "src/style/_variables.scss")],
},
},
chainWebpack(config) {
// set svg-sprite-loader
config.module
.rule("svg")
.exclude.add(resolve("src/icons"))
.end();
config.module
.rule("icons")
.test(/\.svg$/)
.include.add(resolve("src/icons"))
.end()
.use("svg-sprite-loader")
.loader("svg-sprite-loader")
.options({
symbolId: "icon-[name]",
})
.end();
},
configureWebpack: (config) => {
if (process.env.NODE_ENV === "production") {
const productionGzipExtensions = ["html", "js", "css"];
config.plugins.push(
new CompressionWebpackPlugin({
filename: "[path].gz[query]",
algorithm: "gzip",
test: new RegExp("\\.(" + productionGzipExtensions.join("|") + ")$"),
threshold: 10240, // 只有大小大于该值的资源会被处理 10240
minRatio: 0.8, // 只有压缩率小于这个值的资源才会被处理
deleteOriginalAssets: false, // 删除原文件
})
);
}
},
};