diff --git a/package-lock.json b/package-lock.json index 45bbe6db1a..7f3a472365 100644 --- a/package-lock.json +++ b/package-lock.json @@ -93,6 +93,7 @@ "sinon": "^21.0.1", "sinon-chai": "^4.0.0", "tailwindcss": "^4.1.18", + "terser": "^5.46.0", "tsconfig-paths": "^4.2.0", "typescript": "^5.7.2", "typescript-eslint": "^8.26.0", @@ -11494,14 +11495,13 @@ } }, "node_modules/terser": { - "version": "5.42.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.42.0.tgz", - "integrity": "sha512-UYCvU9YQW2f/Vwl+P0GfhxJxbUGLwd+5QrrGgLajzWAtC/23AX0vcise32kkP7Eu0Wu9VlzzHAXkLObgjQfFlQ==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.46.0.tgz", + "integrity": "sha512-jTwoImyr/QbOWFFso3YoU3ik0jBBDJ6JTOQiy/J2YxVJdZCc+5u7skhNwiOR3FQIygFqVUPHl7qbbxtjW2K3Qg==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.14.0", + "acorn": "^8.15.0", "commander": "^2.20.0", "source-map-support": "~0.5.20" }, diff --git a/package.json b/package.json index b99fe1fef9..81580b29b1 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "sinon": "^21.0.1", "sinon-chai": "^4.0.0", "tailwindcss": "^4.1.18", + "terser": "^5.46.0", "tsconfig-paths": "^4.2.0", "typescript": "^5.7.2", "typescript-eslint": "^8.26.0", diff --git a/vite.config.ts b/vite.config.ts index 4b7af9f862..0cde50dd43 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -96,6 +96,18 @@ export default defineConfig(({ mode }) => { outDir: "static", // Webpack outputs to 'static', assuming we want to keep this. emptyOutDir: true, assetsDir: "assets", // Sub-directory for assets + sourcemap: !isProduction, // Source maps for dev builds only + minify: isProduction ? "terser" : false, + ...(isProduction && { + terserOptions: { + toplevel: true, // Mangle top-level names and drop unused top-level vars/functions + compress: { passes: 3 }, + mangle: { toplevel: true }, // Shorten top-level function/variable names + format: { + comments: false, + }, + }, + }), rollupOptions: { output: { manualChunks: {