-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvue.config.js
More file actions
109 lines (106 loc) · 3.62 KB
/
Copy pathvue.config.js
File metadata and controls
109 lines (106 loc) · 3.62 KB
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
/*
* @Author: maggot-code
* @Date: 2021-03-03 22:58:26
* @LastEditors: maggot-code
* @LastEditTime: 2022-09-29 16:01:02
* @Description: file content
*/
// const BundleAnalyzerPlugin =require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const pluginList = [
// new BundleAnalyzerPlugin(),
new LodashModuleReplacementPlugin(),
new CompressionWebpackPlugin({
filename: info => `${info.path}.gz${info.query}`,
algorithm: 'gzip',
threshold: 10240 * 10, // 只有大小大于该值的资源会被处理 10240
test: new RegExp('\\.(' + ['js', 'css', 'json'].join('|') + ')$'),
minRatio: 0.8, // 只有压缩率小于这个值的资源才会被处理
deleteOriginalAssets: false // 删除原文件
})
]
module.exports = {
publicPath: "./",
outputDir: "dist", // 打包输出目录
assetsDir: "static",
productionSourceMap: false,
css: {
// 查看CSS属于哪个css文件
sourceMap: process.env.NODE_ENV === "development",
extract: true,
},
devServer: {
https: false,
open: false,
proxy: {
"/SystemManage": {
target: "http://192.1.1.5:8080",
ws: true,
secure: false,
changeOrigin: true,
pathReWrite: { "^/SystemManage": "" },
},
"/kyhxs": {
target: "http://192.1.1.5:8080",
ws: true,
secure: false,
changeOrigin: true,
pathReWrite: { "^/kyhxs": "" },
},
"/SWZDH": {
target: "http://192.1.1.5:8080",
ws: true,
secure: false,
changeOrigin: true,
pathReWrite: { "^/SWZDH": "" },
},
"/api/node": {
target: "http://127.0.0.1:8000",
ws: true,
secure: false,
changeOrigin: true,
pathReWrite: { "^/api/node": "" },
},
},
},
configureWebpack: (config) => {
// 调试JS
// if (process.env.NODE_ENV === "development") {
// config.devtool = "source-map";
// } else {
// pluginList.push(new BundleAnalyzerPlugin());
// }
if (process.env.NODE_ENV === "development") {
config.devtool = "source-map";
}
//打包文件大小配置
config.performance = {
maxEntrypointSize: 10240 * 100,
maxAssetSize: 10240 * 100,
};
// 公共代码抽离
config.optimization = {
// 分割代码块
splitChunks: {
cacheGroups: {
//公用模块抽离
common: {
chunks: "initial",
minSize: 10240 * 10, //大于0个字节
minChunks: 2, //抽离公共代码时,这个代码块最小被引用的次数
},
vendor: {
priority: 1, //权重
test: /node_modules/,
chunks: "initial",
minSize: 10240 * 10, //大于0个字节
minChunks: 2, //在分割之前,这个代码块最小应该被引用的次数
},
},
},
};
config.plugins.push(...pluginList);
config.mode = process.env.NODE_ENV;
},
};