From 4a4bee658dc1d98ca3bd54aad2d83cc6d6d6b021 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Sun, 1 Mar 2026 19:12:30 +0100 Subject: [PATCH] Add next config for react email dev server --- backend/email/next.config.js | 26 ++++++++++++++++++++++++++ backend/email/package.json | 2 ++ backend/email/tsconfig.test.json | 9 +++------ 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 backend/email/next.config.js diff --git a/backend/email/next.config.js b/backend/email/next.config.js new file mode 100644 index 00000000..838950d1 --- /dev/null +++ b/backend/email/next.config.js @@ -0,0 +1,26 @@ +/** @type {import('next').NextConfig} */ +// eslint-disable-next-line +const path = require('path') +const nextConfig = { + reactStrictMode: true, + swcMinify: true, + experimental: { + serverComponentsExternalPackages: [ + '@react-email/components', + '@react-email/render', + '@react-email/tailwind', + ], + externalDir: true, // compile files that are located next to the .react-email directory + }, + webpack: (config) => { + config.resolve.alias = { + ...config.resolve.alias, + common: path.resolve(__dirname, '../../common/lib'), + shared: path.resolve(__dirname, '../shared/lib'), + email: path.resolve(__dirname, './emails'), + } + return config + }, +} + +module.exports = nextConfig diff --git a/backend/email/package.json b/backend/email/package.json index 9643ae40..56bb447b 100644 --- a/backend/email/package.json +++ b/backend/email/package.json @@ -4,7 +4,9 @@ "private": true, "scripts": { "build": "tsc -b", + "predev": "cp next.config.js .react-email/next.config.js", "dev": "email dev --port 3001", + "postinstall": "echo 'Setting up email dev, stop the process when it says that react email is ready and then run yarn dev' && yarn dev", "lint": "npx eslint . --max-warnings 0", "lint-fix": "npx eslint . --fix", "test": "jest --config jest.config.ts --passWithNoTests", diff --git a/backend/email/tsconfig.test.json b/backend/email/tsconfig.test.json index 58048e7b..5503175c 100644 --- a/backend/email/tsconfig.test.json +++ b/backend/email/tsconfig.test.json @@ -1,17 +1,14 @@ { "extends": "./tsconfig.json", "compilerOptions": { - // Use / as the root for tests so path-mapped imports from - // ../shared and ../../common are within the configured rootDir. - // This avoids TS6059 during ts-jest compilation. - "rootDir": "../..", + "rootDir": ".", "baseUrl": ".", "paths": { "api/*": ["src/*"], "shared/*": ["../shared/src/*"], "common/*": ["../../common/src/*"], - "email/*": ["../email/emails/*"] + "email/*": ["./emails/*"] } }, - "include": ["tests/**/*.ts", "src/**/*.ts"] + "include": ["tests/**/*.ts", "emails/**/*.ts", "emails/**/*.tsx"] }