From bf3f899f1af6b120754cb38411fcfad0b5d396b3 Mon Sep 17 00:00:00 2001 From: Ashot Nazaryan Date: Thu, 9 Jan 2025 04:54:50 -0800 Subject: [PATCH] fix(react-email): Respect user NODE_ENV (#1756) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: gabriel miranda --- .changeset/early-mugs-divide.md | 5 +++++ .../react-email/src/cli/utils/preview/start-dev-server.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/early-mugs-divide.md diff --git a/.changeset/early-mugs-divide.md b/.changeset/early-mugs-divide.md new file mode 100644 index 0000000000..f028c89229 --- /dev/null +++ b/.changeset/early-mugs-divide.md @@ -0,0 +1,5 @@ +--- +"react-email": patch +--- + +Respect user's NODE_ENV when previewing templates diff --git a/packages/react-email/src/cli/utils/preview/start-dev-server.ts b/packages/react-email/src/cli/utils/preview/start-dev-server.ts index b695d82e37..9ae28b1125 100644 --- a/packages/react-email/src/cli/utils/preview/start-dev-server.ts +++ b/packages/react-email/src/cli/utils/preview/start-dev-server.ts @@ -119,8 +119,10 @@ export const startDevServer = async ( // these environment variables are used on the next app // this is the most reliable way of communicating these paths through process.env = { - ...process.env, NODE_ENV: 'development', + ...(process.env as Omit & { + NODE_ENV?: NodeJS.ProcessEnv['NODE_ENV']; + }), ...getEnvVariablesForPreviewApp( // If we don't do normalization here, stuff like https://github.com/resend/react-email/issues/1354 happens. path.normalize(emailsDirRelativePath),