瀏覽代碼

尝试压缩下打包体积

yangzm123 1 年之前
父節點
當前提交
ab795bb7f5
共有 3 個文件被更改,包括 589 次插入171 次删除
  1. 565 169
      package-lock.json
  2. 3 1
      package.json
  3. 21 1
      vue.config.js

File diff suppressed because it is too large
+ 565 - 169
package-lock.json


+ 3 - 1
package.json

@@ -14,7 +14,9 @@
 		"core-js": "^3.6.5",
 		"three": "^0.148.0",
 		"vue": "^2.6.11",
-		"vue-router": "^3.6.5"
+		"vue-router": "^3.6.5",
+		"compression-webpack-plugin": "^5.0.1",
+		"copy-webpack-plugin": "^6.0.4"
 	},
 	"devDependencies": {
 		"@vue/cli-plugin-babel": "~4.5.19",

+ 21 - 1
vue.config.js

@@ -2,14 +2,34 @@
  * @Author: PoJun
  * @Date: 2024-03-14 17:01:20
  * @LastEditors: PoJun
- * @LastEditTime: 2024-04-12 16:20:00
+ * @LastEditTime: 2024-04-15 11:33:37
  * @Message: Nothing
  */
+const CompressionPlugin = require('compression-webpack-plugin');
 module.exports = {
+	productionSourceMap: false,
 	devServer: {
 		open: true,
 		hot: false,
 		inline: false,
 		liveReload: false,
 	},
+	css: {
+		// 是否开启 CSS source maps
+		sourceMap: false,
+		requireModuleExtension: true,
+	},
+	configureWebpack: () => {
+		if (process.env.NODE_ENV === 'production') {
+			return {
+				plugins: [
+					new CompressionPlugin({
+						test: /\.js$|\.css/, // 匹配文件名字
+						threshold: 10240, // 对超过10k的数据进行压缩
+						deleteOriginalAssets: false, // 是否删除源文件
+					}),
+				],
+			};
+		}
+	},
 };

Some files were not shown because too many files changed in this diff