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'],