From 7bb6c0b8267057c2e20a8f834d6e7ce167b8bf09 Mon Sep 17 00:00:00 2001 From: thislight Date: Mon, 28 Oct 2024 18:26:14 +0800 Subject: [PATCH] vite: remove console and debugger stmts in prod --- vite.config.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index 3b37a34..b575b90 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -62,6 +62,8 @@ export default defineConfig(({ mode }) => { ? `${serverHttpCertBase}.crt` : undefined; + const isTestBuild = ["development", "staging"].includes(mode); + return { plugins: [ suid(), @@ -101,6 +103,10 @@ export default defineConfig(({ mode }) => { } : undefined, }, + esbuild: { + pure: isTestBuild ? undefined : ["console.debug", "console.trace"], + drop: isTestBuild ? undefined : ["debugger"], + }, define: { "import.meta.env.BUILT_AT": `"${new Date().toISOString()}"`, },