diff --git a/package-lock.json b/package-lock.json index 3223dfaef..004c70181 100644 --- a/package-lock.json +++ b/package-lock.json @@ -104,6 +104,7 @@ "sinon-chai": "^4.0.0", "style-loader": "^4.0.0", "tailwindcss": "^3.4.17", + "terser-webpack-plugin": "^5.3.14", "ts-loader": "^9.5.2", "tsconfig-paths": "^4.2.0", "tsx": "^4.17.0", @@ -19028,7 +19029,6 @@ "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.14.tgz", "integrity": "sha512-vkZjpUjb6OMS7dhV+tILUW6BhpDR7P2L/aQSAv+Uwk+m8KATX9EccViHTJR2qDtACKPIYndLGCyl3FMo+r2LMw==", "dev": true, - "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "^0.3.25", "jest-worker": "^27.4.5", diff --git a/package.json b/package.json index 31fbc9083..e0b0336cf 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ "sinon-chai": "^4.0.0", "style-loader": "^4.0.0", "tailwindcss": "^3.4.17", + "terser-webpack-plugin": "^5.3.14", "ts-loader": "^9.5.2", "tsconfig-paths": "^4.2.0", "tsx": "^4.17.0", diff --git a/webpack.config.js b/webpack.config.js index baae9ca8a..3c39b5bcd 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,6 +3,7 @@ import CopyPlugin from "copy-webpack-plugin"; import ESLintPlugin from "eslint-webpack-plugin"; import HtmlWebpackPlugin from "html-webpack-plugin"; import path from "path"; +import TerserPlugin from "terser-webpack-plugin"; import { fileURLToPath } from "url"; import webpack from "webpack"; @@ -169,6 +170,25 @@ export default async (env, argv) => { }, }, }, + minimizer: isProduction + ? [ + new TerserPlugin({ + terserOptions: { + keep_classnames: (name) => + /Layer$|Display$|Menu$|Timer$|Sidebar$|Panel$|Overlay$|Modal$/.test( + name, + ) || + name === "Leaderboard" || + name === "TeamStats" || + name === "HeadsUpMessage" || + name === "AlertFrame" || + name === "TerritoryWebGLStatus" || + name === "MainRadialMenu" || + name === "AdTimer", + }, + }), + ] + : [], }, devServer: isProduction ? {}