-
Notifications
You must be signed in to change notification settings - Fork 8
/
vue.config.js
112 lines (110 loc) · 3.28 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const path = require("path");
const CompressionPlugin = require("compression-webpack-plugin");
function resolve(dir) {
return path.join(__dirname, dir);
}
// const isProd = process.env.NODE_ENV === 'production'
// const cdn = {
// externals: {
// vue: 'Vue',
// 'vue-router': 'VueRouter',
// vuex: 'Vuex',
// axios: 'axios',
// 'ant-design-vue': 'antd',
// 'vue-ls': 'VueStorage',
// },
// css: [],
// js: [
// '//unpkg.com/[email protected]/dist/vue.min.js',
// '//unpkg.com/[email protected]/dist/vue-router.min.js',
// '//unpkg.com/[email protected]/dist/vuex.min.js',
// '//unpkg.com/[email protected]/dist/axios.min.js',
// '//unpkg.com/[email protected]/dist/antd.min.js',
// '//unpkg.com/[email protected]/dist/vue-ls.min.js',
// ]
// };
module.exports = {
publicPath: process.env.NODE_ENV === "production" ? "/" : "/",
outputDir: "dist",
assetsDir: "static",
lintOnSave: false,
devServer: {
before(app) {
app.get(/.*.(js)$/, (req, res, next) => {
req.url = req.url + '.gz';
res.set('Content-Encoding', 'gzip');
next();
})
},
open: false,
hotOnly: true,
host: "localhost",
port: 8080,
proxy: {
"/mgr": {
target: "http://127.0.0.1/",
// ws: true,
changeOrigin: true,
pathRewrite: {
"^/mgr": "",
},
},
},
},
productionSourceMap: false,
chainWebpack: (config) => {
config.plugins.delete("preload");
config.plugins.delete("prefetch");
config.optimization.minimize(true);
config.optimization.splitChunks({
chunks: 'all'
})
config.resolve.alias
.set("@", resolve("./src"))
.set("assets", resolve(".src/assets"))
.set("components", resolve("./src/components"))
.set("views", resolve("src/views"));
const svgRule = config.module.rule("svg");
svgRule.uses.clear();
svgRule
.test(/\.svg$/)
.include.add(path.resolve(__dirname, "./src/svgIcons"))
.end()
.use("svg-sprite-loader")
.loader("svg-sprite-loader")
.options({
symbolId: "icon-[name]",
});
const fileRule = config.module.rule("file");
fileRule.uses.clear();
fileRule
.test(/\.svg$/)
.exclude.add(path.resolve(__dirname, "./src/svgIcons"))
.end()
.use("file-loader")
.loader("file-loader");
},
css: {
loaderOptions: {
postcss: {
plugins: [
require("postcss-pxtorem")({
rootValue: 37.5,
propList: ["*"],
}),
],
},
},
},
configureWebpack: {
plugins: [
new CompressionPlugin({
algorithm: "gzip",
test: /\.js$|\.css$/,
filename: "[path].gz[query]",
minRatio: 0.8,
threshold: 10240,
}),
],
},
};