shellscape / jsx-email

Build emails with a delightful DX
https://jsx.email
MIT License
895 stars 28 forks source link

fix(app-preview): use relative path replacement, fixes prod build #153

Closed shellscape closed 5 months ago

shellscape commented 5 months ago

Component / Package Name:

This PR contains:

Are tests included?

Breaking Changes?

If yes, please include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

This PR resolves an issue with email preview --build-path where vite creates a production build for deployment. With using the as: 'url' method of import.meta.glob to get the file paths of the templates loaded in production, we're given back completely different values than running in dev. Many of those values are base64 octet data urls, which is useless for our needs. The clue to a fix was the relative path that vite was using. Calculating that ourselves and injecting it into the bundle gave us something that we could use in both prod and dev preview apps.