react-email icon indicating copy to clipboard operation
react-email copied to clipboard

Sending emails with Tailwind in Nitro fail

Open mariusflorescu opened this issue 1 year ago • 9 comments

I'm running a tanstack start application inside a turborepo with pnpm.

All my emails are tailwind-based and they fail to be sent. I've got a reproduction repository here.

The issue happens only in production build. The error message that gets logged is TypeError: f.split is not a function .

I don't know if that's a react-email or resend SDK issue, feel free to move it if here's not the right place.

mariusflorescu avatar Apr 22 '25 10:04 mariusflorescu

Seems to be a Resend SDK issue. Tried rendering with and without the Node SDK. A good workaround for now is to just render the email template yourself and use the html option, which seems to work.

gabrielmfern avatar Aug 05 '25 16:08 gabrielmfern

Actually, seems like just having @react-email/components installed in app/web makes the error go away. Not absolutely sure why

gabrielmfern avatar Aug 05 '25 17:08 gabrielmfern

Seems to also be related to React Email's Tailwind component, if I remove it from the email template it works too

gabrielmfern avatar Aug 05 '25 17:08 gabrielmfern

This issue is indeed React Email related, if the server function just instantiates the email template it already fails after build

gabrielmfern avatar Aug 05 '25 18:08 gabrielmfern

so what do we do as a work around?

stunaz avatar Sep 07 '25 07:09 stunaz

Id like to give this a try

sccalabr avatar Oct 04 '25 17:10 sccalabr

Hi, I would like to give this a try. Can you assign the issue to me?

kazekunal avatar Oct 21 '25 19:10 kazekunal

I think this one was fixed already. I used the reproduction repo provided by @mariusflorescu and could send emails successfully. BTW, sorry @mariusflorescu, I sent you an email accidentally.

For the repo, found an issue on run pnpm dev

[plugin:vite:css] Failed to load PostCSS config (searchPath: /MY_PROJECT_FOLDER/tanstack-start-resend-issue/apps/web): [Error] Loading PostCSS Plugin failed: Cannot find module '@tailwindcss/postcss'
Require stack:
- /MY_PROJECT_FOLDER/tanstack-start-resend-issue/apps/web/postcss.config.mjs

(@/MY_PROJECT_FOLDER/tanstack-start-resend-issue/apps/web/postcss.config.mjs)
Error: Loading PostCSS Plugin failed: Cannot find module '@tailwindcss/postcss'
Require stack:
- /MY_PROJECT_FOLDER/tanstack-start-resend-issue/apps/web/postcss.config.mjs

(@/MY_PROJECT_FOLDER/tanstack-start-resend-issue/apps/web/postcss.config.mjs)
    at load (file:///MY_PROJECT_FOLDER/tanstack-start-resend-issue/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-ByPKlqZ5.js:14869:11)
    at async Promise.all (index 0)
    at async plugins (file:///MY_PROJECT_FOLDER/tanstack-start-resend-issue/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-ByPKlqZ5.js:14898:12)
    at async processResult (file:///MY_PROJECT_FOLDER/tanstack-start-resend-issue/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-ByPKlqZ5.js:14969:14)
/MY_PROJECT_FOLDER/tanstack-start-resend-issue/apps/web/src/styles/globals.css

I found that issue by running pnpm dev. The reason why that's happening is that you have a postcss.config.mjs file in apps/web folder. When using the Vite plugin for Tailwind v4, you don't need a separate postcss config file. The postcss config is conflicting with your Vite plugin setup. Stopping dev server and rm apps/web/postcss.config.mjs (remove the file) is the solution for that issue. Run pnpm dev once again, and you'll see that the problem is gone.

After fixing that issue, I was able to send emails and I couldn't reproduce the react.email problem that was reported here.

devthiago avatar Feb 05 '26 13:02 devthiago

That's extremely helpful @devthiago, thank you, closing as not planned.

gabrielmfern avatar May 22 '26 13:05 gabrielmfern