Sending emails with Tailwind in Nitro fail
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.
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.
Actually, seems like just having @react-email/components installed in app/web makes the error go away. Not absolutely sure why
Seems to also be related to React Email's Tailwind component, if I remove it from the email template it works too
This issue is indeed React Email related, if the server function just instantiates the email template it already fails after build
so what do we do as a work around?
Id like to give this a try
Hi, I would like to give this a try. Can you assign the issue to me?
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.
That's extremely helpful @devthiago, thank you, closing as not planned.