From 24cd01dd31e0a5bdd130d2c895efe3dece09ab66 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 28 Jul 2024 10:45:32 -0500 Subject: [PATCH] fix: Don't default to dev mode for production builds when using `vite-node` loader (#877) --- packages/wxt/src/core/wxt.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/wxt/src/core/wxt.ts b/packages/wxt/src/core/wxt.ts index 7862b2879..2d2108068 100644 --- a/packages/wxt/src/core/wxt.ts +++ b/packages/wxt/src/core/wxt.ts @@ -27,6 +27,10 @@ export async function registerWxt( inlineConfig: InlineConfig = {}, getServer?: (config: ResolvedConfig) => Promise, ): Promise { + // Default NODE_ENV environment variable before other packages, like vite, do it + // See https://github.com/wxt-dev/wxt/issues/873#issuecomment-2254555523 + process.env.NODE_ENV ??= command === 'serve' ? 'development' : 'production'; + const hooks = createHooks(); const config = await resolveConfig(inlineConfig, command); const server = await getServer?.(config);