From 429e44f74da3db68a002e7fac805b6c08e65e50e Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Thu, 15 Aug 2024 14:41:36 -0400 Subject: [PATCH] Control minify with env var (#445) --- .env_example | 5 ++++- vite.config.mts | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.env_example b/.env_example index 92a1dd34a..79971384d 100644 --- a/.env_example +++ b/.env_example @@ -13,4 +13,7 @@ DEV_SERVER_COMFYUI_URL=http://127.0.0.1:8188 DEPLOY_COMFYUI_DIR=/home/ComfyUI/web # The directory containing the ComfyUI_examples repo used to extract test workflows. -EXAMPLE_REPO_PATH=tests-ui/ComfyUI_examples \ No newline at end of file +EXAMPLE_REPO_PATH=tests-ui/ComfyUI_examples + +# Whether to enable minification of the frontend code. +ENABLE_MINIFY=true \ No newline at end of file diff --git a/vite.config.mts b/vite.config.mts index 6df89c707..99318f0f6 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -5,6 +5,7 @@ import dotenv from "dotenv"; dotenv.config(); const IS_DEV = process.env.NODE_ENV === 'development'; +const SHOULD_MINIFY = process.env.ENABLE_MINIFY !== 'false'; interface ShimResult { code: string; @@ -111,7 +112,7 @@ export default defineConfig({ comfyAPIPlugin(), ], build: { - minify: 'esbuild', + minify: SHOULD_MINIFY ? 'esbuild' : false, target: 'es2015', sourcemap: true, rollupOptions: { @@ -123,8 +124,8 @@ export default defineConfig({ esbuild: { minifyIdentifiers: false, keepNames: true, - minifySyntax: true, - minifyWhitespace: true, + minifySyntax: SHOULD_MINIFY, + minifyWhitespace: SHOULD_MINIFY, }, define: { '__COMFYUI_FRONTEND_VERSION__': JSON.stringify(process.env.npm_package_version),