From d67bfffe624bb48bd58fcc34ca6abb92abd0a5dd Mon Sep 17 00:00:00 2001 From: scamiv <6170744+scamiv@users.noreply.github.com> Date: Sun, 8 Feb 2026 04:05:17 +0100 Subject: [PATCH] build: use Terser for production minification - Add terser devDependency and set build.minify to "terser" in production - Enable source maps only for non-production builds - Disable minification for dev builds - Terser options: mangle names, strip comments, 2 compress passes --- package.json | 1 + vite.config.ts | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/package.json b/package.json index b99fe1fef..12049dbd5 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.42.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 4b7af9f86..049c00954 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -96,6 +96,17 @@ 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: { + compress: { passes: 2 }, + mangle: true, + format: { + comments: false, + }, + }, + }), rollupOptions: { output: { manualChunks: {