From 1287ded97ecce49e7135be5e2d6ba6ed7e88fb02 Mon Sep 17 00:00:00 2001 From: Julio Lima Date: Fri, 7 Nov 2025 05:21:34 +0100 Subject: [PATCH] Make the path generic. To able to build locally and use NextJS just changing the root dir. --- packages/react-email/src/commands/build.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/react-email/src/commands/build.ts b/packages/react-email/src/commands/build.ts index 0fe3fe1e1a..4fd76d4502 100644 --- a/packages/react-email/src/commands/build.ts +++ b/packages/react-email/src/commands/build.ts @@ -78,14 +78,15 @@ const setNextEnvironmentVariablesForBuild = async ( const nextConfigContents = ` const path = require('path'); const emailsDirRelativePath = path.normalize('${emailsDirRelativePath}'); -const userProjectLocation = '${process.cwd().replace(/\\/g, '/')}'; +const userProjectLocation = path.resolve(__dirname, "../"); +const reactEmailDir = ".react-email"; /** @type {import('next').NextConfig} */ module.exports = { env: { NEXT_PUBLIC_IS_BUILDING: 'true', EMAILS_DIR_RELATIVE_PATH: emailsDirRelativePath, EMAILS_DIR_ABSOLUTE_PATH: path.resolve(userProjectLocation, emailsDirRelativePath), - PREVIEW_SERVER_LOCATION: '${builtPreviewAppPath.replace(/\\/g, '/')}', + PREVIEW_SERVER_LOCATION: path.join(userProjectLocation, reactEmailDir), USER_PROJECT_LOCATION: userProjectLocation }, serverExternalPackages: ['esbuild'],