From 2018f1e671dbc758db07ec89ab3f900e86e5ea01 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 18 Oct 2025 22:43:38 -0700 Subject: [PATCH] [ci] drop console statements (except `warn` and `error`) when building app (#6123) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Marks all the console methods besides `warn` and `error` as pure functions so they can be dropped during DCE in build pipeline. It's simpler to use `drop` but that would remove errors/warnings. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6123-ci-drop-console-statements-except-warn-and-error-when-building-app-2906d73d365081f28303c0d784352b12) by [Unito](https://www.unito.io) --- vite.config.mts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/vite.config.mts b/vite.config.mts index 2ede27470..df9481d16 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -196,7 +196,29 @@ export default defineConfig({ minifyIdentifiers: SHOULD_MINIFY, keepNames: true, minifySyntax: SHOULD_MINIFY, - minifyWhitespace: SHOULD_MINIFY + minifyWhitespace: SHOULD_MINIFY, + pure: SHOULD_MINIFY + ? [ + 'console.log', + 'console.debug', + 'console.info', + 'console.trace', + 'console.dir', + 'console.dirxml', + 'console.group', + 'console.groupCollapsed', + 'console.groupEnd', + 'console.table', + 'console.time', + 'console.timeEnd', + 'console.timeLog', + 'console.count', + 'console.countReset', + 'console.profile', + 'console.profileEnd', + 'console.clear' + ] + : [] }, test: {