Skip to content

Deploying static site to subfolder leads to 404s for most assets in SvelteKit v1.22.1 #10358

Closed
@danieldiekmeier

Description

@danieldiekmeier

Describe the bug

Starting with SvelteKit 1.22.1, using adapter-static to deploy to a subfolder no longer works. It seems likely that the change from https://github.com/sveltejs/kit/releases/tag/%40sveltejs%2Fkit%401.22.1 is responsible:

perf: only have Vite generate relative paths when required

I noticed probably relevant changes in build/_app/immutable/entry/app.*.js:

  • In 1.22.0, it loads additional JS chunks from a relative path, like ../chunks/...
  • In 1.22.1, it loads them from _app/immutable/chunks/..., which does not work.

@benmccann suggested that paths.relative may fix it, but it doesn't seem like that to me.

Screenshot 2023-07-10 13 47 53@2x

I prepared a minimal reproduction that demonstrates and explains this better than a lot of prose, I think.


My current workaround is to downgrade back to SvelteKit 1.22.0.

Reproduction

https://github.com/danieldiekmeier/reproduction-sveltekit-relative

Reproduction steps are in the README.md.

Logs

No response

System Info

System:
    OS: macOS 13.4.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 83.11 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.asdf/installs/nodejs/18.16.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/installs/nodejs/18.16.0/bin/yarn
    npm: 9.5.1 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 114.0.5735.198
    Edge: 113.0.1774.57
    Firefox: 103.0.2
    Firefox Developer Edition: 114.0
    Safari: 16.5.1
    Safari Technology Preview: 17.0
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.1.0 
    @sveltejs/adapter-static: ^2.0.2 => 2.0.2 
    @sveltejs/kit: ^1.22.1 => 1.22.1 
    svelte: ^4.0.0 => 4.0.5 
    vite: ^4.3.6 => 4.4.2

Severity

blocking an upgrade

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions