Skip to content

Assets are not included for the server (adapter-node) #5240

@maximedupre

Description

@maximedupre

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.

import Image from '$lib/svelte-welcome.webp';

console.log(Image); // /_app/immutable/assets/svelte-welcome-c18bcf5a.webp

When looking in /build/client/_app/immutable/assets folder, the file is not included.

Use case

  1. I am using node-canvas on the server and in this case, I need to place an image on the canvas, so I need the image path
  2. This is not an asset that I want to share publically, which is why I don't want to have it in the static folder

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-eromzr?file=src/routes/todos/_api.js

  1. Run npm run build
  2. Run node build
  3. Click on the "Todos" link
  4. See image path in the console

Logs

No response

System Info

This command doesn't seem to work on StackBlitz 😄

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready to implementplease submit PRs for these issues!vite

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions