wix-incubator / mjml-react

React component library to generate the HTML emails on the fly
MIT License
988 stars 50 forks source link

Uncaught ReferenceError: process is not defined (Vite + TS + SWC) #98

Closed viktorkasap closed 1 year ago

viktorkasap commented 1 year ago

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

import {
  render,
  Mjml,
  MjmlHead,
  MjmlTitle,
  MjmlPreview,
  MjmlBody,
  MjmlSection,
  MjmlColumn,
  MjmlButton,
  MjmlImage,
} from "mjml-react";

const { html, errors } = render(
  <Mjml>
    <MjmlHead>
      <MjmlTitle>Last Minute Offer</MjmlTitle>
      <MjmlPreview>Last Minute Offer...</MjmlPreview>
    </MjmlHead>
    <MjmlBody width={500}>
      <MjmlSection fullWidth backgroundColor="#efefef">
        <MjmlColumn>
          <MjmlImage src="https://static.wixstatic.com/media/5cb24728abef45dabebe7edc1d97ddd2.jpg" />
        </MjmlColumn>
      </MjmlSection>
      <MjmlSection>
        <MjmlColumn>
          <MjmlButton
            padding="20px"
            backgroundColor="#346DB7"
            href="https://www.wix.com/"
          >
            I like it!
          </MjmlButton>
        </MjmlColumn>
      </MjmlSection>
    </MjmlBody>
  </Mjml>,
  { validationLevel: "soft" }
);

Result

 rewrite-url.js:16 Uncaught ReferenceError: process is not defined
    at node_modules/clean-css/lib/reader/rewrite-url.js (rewrite-url.js:16:17)
    at __require2 (chunk-6FBSFQRG.js?v=7779ef7f:18:50)
    at node_modules/clean-css/lib/reader/rebase.js (rebase.js:3:18)
    at __require2 (chunk-6FBSFQRG.js?v=7779ef7f:18:50)
    at node_modules/clean-css/lib/reader/read-sources.js (read-sources.js:9:14)
    at __require2 (chunk-6FBSFQRG.js?v=7779ef7f:18:50)
    at node_modules/clean-css/lib/clean.js (clean.js:25:19)
    at __require2 (chunk-6FBSFQRG.js?v=7779ef7f:18:50)
    at node_modules/clean-css/index.js (index.js:1:18)
    at __require2 (chunk-6FBSFQRG.js?v=7779ef7f:18:50)
daliusd commented 1 year ago

Hey, please try using this fork https://github.com/Faire/mjml-react . This is not maintained project anymore.