diff --git a/packages/wxt/src/core/wxt.ts b/packages/wxt/src/core/wxt.ts index 7862b287..2d210806 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);