-
-
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
prerendering does not crawl imported images outside of pages #1567
Comments
npm run build
with @sveltejs/adapter-static results
in 404 error for image file
npm run build
with @sveltejs/adapter-static results
in 404 error for image filenpm run build
with static adapter gives 404 error for image file
npm run build
with static adapter gives 404 error for image filenpm run build
with adapter-static
gives 404 error for image file
This only happens for prerendered pages. Images imported images outside of pages, in this case an endpoint, does not get crawled. The error would also appear if we use adapter-node and set |
npm run build
with adapter-static
gives 404 error for image file
This is because assets are only generated for the client side builds (which doesn't bundle endpoints). SSR builds (which bundles endpoints) don't generate assets. To workaround this, you can specify all the possible links from SSR in the client bundle like this, which shouldn't impact bundle size, but not the most ergonomic way of handling it. I'm not sure how we should handle this though, perhaps SvelteKit can have Vite crawl for asset imports in endpoints. I also think I've seen a similar issue in Vite but I can't find it. |
Converting images to a blob worked for me as a workaround. The +server.ts returns this:
|
closing as a dupe of #5240 (even though this issue was first) — the underlying issue is vitejs/vite#11429, and there's a fix here vitejs/vite#11430 |
Describe the bug
routes/todos/index.json.ts
imports an image. When using@sveltejs/adapter-static
,npm run build
produces a 404 errorLogs
To Reproduce
Checkout https://github.com/PingTouG/svelte-kit-bug. An image was added to the todos tab as shown below
src/routes/todos/index.json.ts
src/routes/todos/index.svelte
Expected behavior
npm run build
is okInformation about your SvelteKit Installation:
Diagnostics
@sveltejs/kit : next
@sveltejs/adapter-static : ^1.0.0-next.11
svelte : ^3.34.0
chorme
Severity
The website cannot run
The text was updated successfully, but these errors were encountered: