-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught ReferenceError: process is not defined (Vite + TS + SWC) #93
Comments
This looks to me like it is coming from For the quickest resolution I would suggest trying to write your own render function that modifies the one provided and doesn't use html-minifier. There is an example here of one that doesn't use html-minifier. |
Thank you for answer I tried to create render.js file
But it doesn't help, maybe I'm doing something wrong... |
I made sandbox project for testing, could you check it out please please? |
Interesting, thank you for sharing the sandbox. It looks like import mjml2html from "mjml-browser"; // This update should be the key to your fix
import React from "react";
import ReactDOMServer from "react-dom/server";
function renderToMjml(email) {
return ReactDOMServer.renderToStaticMarkup(email);
}
export function render(
email,
options= {}
) {
return mjml2html(renderToMjml(email), options);
} You could also create an alias that maps mjml to mjml-browser, but that one line in the render should be the only place you need to replace it. |
Yes! It works! |
Happy to hear! You're welcome 🎉 Note: I am closing this but will be discussing better documentation/a better plan for handling mjml vs mjml-browsers for this project moving forward, so hopefully we can make this less confusing soon. |
I've this error in Vite project
Steps:
1
npm create vite
-> React -> TypeScript+SWC (and without SWC)2
yarn add mjml mjml-react
3 Added this example to App.tsx
Result
The text was updated successfully, but these errors were encountered: