vite: remove console and debugger stmts in prod

This commit is contained in:
thislight 2024-10-28 18:26:14 +08:00
parent 93f98059cd
commit 7bb6c0b826
No known key found for this signature in database
GPG key ID: A50F9451AC56A63E

View file

@ -62,6 +62,8 @@ export default defineConfig(({ mode }) => {
? `${serverHttpCertBase}.crt` ? `${serverHttpCertBase}.crt`
: undefined; : undefined;
const isTestBuild = ["development", "staging"].includes(mode);
return { return {
plugins: [ plugins: [
suid(), suid(),
@ -101,6 +103,10 @@ export default defineConfig(({ mode }) => {
} }
: undefined, : undefined,
}, },
esbuild: {
pure: isTestBuild ? undefined : ["console.debug", "console.trace"],
drop: isTestBuild ? undefined : ["debugger"],
},
define: { define: {
"import.meta.env.BUILT_AT": `"${new Date().toISOString()}"`, "import.meta.env.BUILT_AT": `"${new Date().toISOString()}"`,
}, },