fix(jsx-email): allow preview server to serve files outside of workspace root #105
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since the preview app is tucked away in node_modules, it doesn't allow for files to be served from a consumer's actual project root. This would help by serving local files (ex static/cat.png) during development
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
I'm really excited to use this repo! I made some contributions to the the OG react-email project, but it is time to update things, so I'm taking this out for a spin.
I really like the simplified dev env through vite, that seems much more intuitive to me as well. However, I'd like replicate some behavior that we built a bit of our CI tooling around: static asset handling.
react-emailwould do a very large and spooky copy/paste of assets in order to make them available during development. I'd like to keep the feature of using local assets in development.Turning of vite's
fs.strictfield allows a dev to import (viaimport.meta.resolve) a local file that is outside of the vite preview project, which is nestled deep in node_modules.Unless there is a more canonical why of doing this, check out my example I added to the docs for how it could work (and does with a monkey patch on my project).
(I'd like help with tests, I wasn't sure how to integrate using
import.meta.resolvein the test file because the tsconfig module was not set toESNext.I tried with
pathand__dirname, but then also realized that it would resolve to the local machine, not the test env 😬 LMK!)