Add TerserPlugin to preserve layer class names in production builds

- Install terser-webpack-plugin dependency
- Configure keep_classnames with regex pattern for layer classes
- Preserve names for FrameProfiler layer identification in production
- Covers most layer classes with regex, handles exceptions explicitly
This commit is contained in:
scamiv
2025-11-20 22:43:05 +01:00
parent c3796acd9b
commit 1f1e0341cf
3 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -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",
+1
View File
@@ -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",
+20
View File
@@ -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
? {}