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.
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
feat: include server assets for Vercel serverless functions #10979
feat: include server assets for Vercel serverless functions #10979
Changes from 1 commit
cbed243
4915822
fc081d0
e45f4ce
045f343
eeb1cf5
9ec0f82
ac6f3f7
9ce6edb
d8aec4b
ad67ee2
407af73
df45d57
efa240d
816fe44
09a28fb
7390ed8
2c9e86c
957dc06
396d48c
bb1d891
3449ca2
8fbc1aa
306dcde
71a722c
5e09b0b
7625adb
028f35e
9401f07
abafe51
7312bd9
010081f
d8dbb21
d75ad7c
9d0e3a4
9d93465
2355ef6
ea274ec
2784729
82488f6
928d53b
39745e6
cde2295
7699bfd
c4ee169
627cce8
3ac5e78
0e78235
084d97b
c2f8c84
80a6bab
068ded2
557e4e1
8dcb57c
125ac3f
fc09cb7
821c673
c96c33d
3b7127a
463ffb9
cb58b72
6f0fcc0
88b6800
3a0929c
509a698
9f03b6b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the use-case for having a font rendered with a PDF is great, but perhaps something simpler like just serving up a .txt file is more concise example. This example sort-of requires understanding of how PDFs are rendered, and includes both streaming code and use of temporary intermediate files (which is also good to have documented somewhere, but conflating the two concepts here might be a bit much).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vite inlines the imported text file so it doesn’t get copied as an asset. I couldn’t think of another example and followed the one provided by Vercel. I’ll try to think up of something else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you just not import it? My use case was that i'm compiling mjml - I import the templates with ?raw which is great, but the mjml compiler needs to know about an "includes" dir which it grabs files from when it compiles the mjml to html. I spent hours, and hours trying to get this to work on Vercel.
As I mentioned before it might be esoteric, but I'm sure there is another use-case - I've struggled with static files before when trying to grab compiled runtimes out of the "sharp" package and forcing them to deploy to Vercel as it does an fs.readFile at runtime to grab the compiled bundle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it has to be imported so Vite’s asset handling kicks in and we grab the processed asset urls off the vite manifest https://vitejs.dev/guide/assets could you share a code example of how your use case is being implemented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting - so I guess my question is, would this work if I wanted to include a directory full of assets, without specifically
import
ing each one. My code looks like this:and then in my code I can reference this dir so that the mjml knows where to find its files. No imports required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that post-build script should work great #10594 (comment) . Someone tried something similar here https://github.com/syntaxfm/website/pull/1179/files#diff-d3309f83fe6f5a74a8d1dde6c819338f4550d93f9308702c018eeb3692955f14 This PR is more of convenience, and especially if split functions are enabled.
You could also use the glob import to get multiple file paths https://vitejs.dev/guide/features.html#glob-import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The post-build feels brittle, but I guess until there is more demand for this sort of thing, it's a fine solution.