From cfa95f03007b221f1e00f4bf5cd29c3ccea3a0a7 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 09 Feb 2022 10:26:00 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/school-web
---
vue.config.js | 49 ++++++++++++++++++++-----------------------------
1 files changed, 20 insertions(+), 29 deletions(-)
diff --git a/vue.config.js b/vue.config.js
index e3774b4..244d46f 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -3,15 +3,11 @@
const dvgisDist = "./node_modules/@dvgis";
//减少chunk-vendors.js文件大小
-// const webpack = require("webpack");
-// const CompressionWebpackPlugin = require("compression-webpack-plugin");
-// const productionGzipExtensions = ["js", "css"];
-// const isProduction = process.env.NODE_ENV === "production";
+const CompressionPlugin = require("compression-webpack-plugin");
module.exports = {
publicPath: "/",
lintOnSave: false,
-
// 其他配置
chainWebpack: (config) => {
config.plugin("copy").use(CopywebpackPlugin, [
@@ -39,28 +35,23 @@
],
]);
},
- //减少chunk-vendors.js文件大小 报错 TypeError: Cannot read property 'tapPromise' of undefined
- // configureWebpack: {
- // resolve: {
- // alias: {
- // "@": path.resolve(__dirname, "./src"),
- // "@i": path.resolve(__dirname, "./src/assets"),
- // },
- // },
- // plugins: [
- // new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
-
- // // 下面是下载的插件的配置
- // new CompressionWebpackPlugin({
- // algorithm: "gzip",
- // test: new RegExp("\\.(" + productionGzipExtensions.join("|") + ")$"),
- // threshold: 10240,
- // minRatio: 0.8,
- // }),
- // new webpack.optimize.LimitChunkCountPlugin({
- // maxChunks: 5,
- // minChunkSize: 100,
- // }),
- // ],
- // },
+ //减少chunk-vendors.js文件大小
+ // 报错 TypeError: Cannot read property 'tapPromise' of undefined
+ //解决 ,把compression-webpack-plugin包退回成 compression-webpack-plugin@5.0.1 即可
+ //文件由8M 减成2.5M
+ productionSourceMap: false, //代码压缩加密
+ configureWebpack: {
+ // webpack plugins
+ plugins: [
+ //提供带 Content-Encoding 编码的压缩版的资源
+ new CompressionPlugin({
+ algorithm: "gzip",
+ test: /\.js$|\.html$|\.css/, // 匹配文件名
+ // test: /\.(js|css)$/,
+ threshold: 10240, // 对超过10k的数据压缩
+ deleteOriginalAssets: false, // 不删除源文件
+ minRatio: 0.8, // 压缩比
+ }),
+ ],
+ },
};
--
Gitblit v1.9.3