-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Assets are not included for the server (adapter-node) #5240
Comments
This is a serious issue ! Because assets are now considered as route by the layout... so it throws a 404 and even could erase $page.stuff if you use it for metadata in your __error.svelte |
This comment was marked as off-topic.
This comment was marked as off-topic.
possibly related: #1567 |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Opened vitejs/vite#11429 |
Not ideal, but may be necessary for the time being, as there may be an underlying issue with SvelteKit/Vite re: the use of assets on the server side. See <sveltejs/kit#5240> for more details (at least I *think* this may be the root cause).
Not ideal, but may be necessary for the time being, as there may be an underlying issue with SvelteKit/Vite re: the use of assets on the server side. See <sveltejs/kit#5240> for more details (at least I *think* this may be the root cause).
Does a workaround exist? |
Yes, import the assets somewhere in your client code. As long as you don't use them in client code, the paths will be treeshaken away so they won't impact your client-side bundle size. |
I just tried vite 4.1.0-beta.1 which should have the fix from vitejs/vite#11429 and my similar error still occurs, are others still seeing the same thing? For reference, my issue is a file |
@thechubbypanda I'm also still facing the error with vite 4.1.0-beta.1, but I don't think it includes the fix, since it's not on the changelog document yet. Edit: seems like it was added to the changelog (as #11430) but the error still occurs with Vite 4.1.1 |
This was accomplished by moving the thumbnail generation (using vite-imagetools) from the server to the client. This is supposedly because SvelteKit does not currently have support for loading non-raw assets on the server side (per <sveltejs/kit#5240>). At least, moving the logic to the front end worked like a charm.
I had a similar issue with production. I used as But when i put the url as variable in the script, and did an inline styling lin |
Vite 4.1 will copy the server assets to |
Describe the bug
Bug
If you import an image on the server (e.g. in an endpoint), the file path will point to a non-existent file.
When looking in
/build/client/_app/immutable/assets
folder, the file is not included.Use case
node-canvas
on the server and in this case, I need to place an image on the canvas, so I need the image pathstatic
folderReproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-eromzr?file=src/routes/todos/_api.js
npm run build
node build
Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
I guess I can work around it by having all assets in the
static
folder, which is included in the build correctly.But then all the assets are public. So then I guess I can have some sort of logic in
hooks.ts
that would prevent access to those files.The text was updated successfully, but these errors were encountered: