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),