From 2e07c8b03984edeffeb7b8cfb7513ae0b40e5a6e Mon Sep 17 00:00:00 2001 From: guangzan Date: Sun, 28 Aug 2022 22:31:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=F0=9F=94=A8=20remove=20console,?= =?UTF-8?q?=20debugger=20via=20esbuild=20drop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 38a8019..71bd632 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -73,12 +73,11 @@ export default defineConfig((mode: ConfigEnv): UserConfig => { }) ], esbuild: { - pure: viteEnv.VITE_DROP_CONSOLE ? ["console.log", "debugger"] : [] + drop: viteEnv.VITE_DROP_CONSOLE ? ["console", "debugger"] : [] }, // build configure build: { outDir: "dist", - // esbuild 打包更快,但是不能去除 console.log,去除 console 使用 terser 模式 minify: "esbuild", // minify: "terser", // terserOptions: { From 13867890f9b81eee33910cedb5ef3c5ed50c9626 Mon Sep 17 00:00:00 2001 From: guangzan Date: Mon, 29 Aug 2022 00:12:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A8=20drop=20console,=20debugger?= =?UTF-8?q?=20in=20production=20env=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 71bd632..aaecfe4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -73,7 +73,7 @@ export default defineConfig((mode: ConfigEnv): UserConfig => { }) ], esbuild: { - drop: viteEnv.VITE_DROP_CONSOLE ? ["console", "debugger"] : [] + drop: viteEnv.VITE_DROP_CONSOLE && mode.mode === "production" ? ["console", "debugger"] : [] }, // build configure build: {