Skip to content
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

Generated URLs are inconsistent to the basepath with adapter-static #2697

Closed
illright opened this issue Oct 28, 2021 · 3 comments · Fixed by #3234
Closed

Generated URLs are inconsistent to the basepath with adapter-static #2697

illright opened this issue Oct 28, 2021 · 3 comments · Fixed by #3234
Labels
feature / enhancement New feature or request p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc.
Milestone

Comments

@illright
Copy link
Contributor

Describe the bug

Sapper was gracefully handling non-root basepaths by injecting a <base> tag into <head> in place of %sapper.base%. SvelteKit doesn't have that, but it does have kit.paths.base. By changing it, the auto-generated URLs of SvelteKit are rebased, but if there were any previous static URLs, for example, a favicon in app.html, these URLs will be broken.

Due to the fact that there are now both rebased and non-rebased URLs on a page, this can no longer be remedied by injecting a <base> tag with a hook, as @benmccann suggested in illright/attractions#311 (comment).

Reproduction

https://github.com/illright/sveltekit-repro-basepath

Logs

No response

System Info

System:
    OS: Linux 5.14 Manjaro Linux
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    Memory: 3.16 GB / 7.62 GB
    Container: Yes
    Shell: 3.3.1 - /usr/bin/fish
  Binaries:
    Node: 16.11.0 - /usr/bin/node
    npm: 8.0.0 - /usr/bin/npm
  Browsers:
    Firefox: 93.0
  npmPackages:
    @sveltejs/adapter-static: ^1.0.0-next.21 => 1.0.0-next.21 
    @sveltejs/kit: next => 1.0.0-next.191 
    svelte: ^3.42.6 => 3.44.0

Severity

blocking all usage of SvelteKit

Additional Information

This blocks reliable deployment of SvelteKit-generated websites to GitHub Pages.

@benmccann benmccann added feature / enhancement New feature or request p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. labels Oct 28, 2021
@benmccann benmccann added this to the 1.0 milestone Oct 28, 2021
@mgrubinger
Copy link
Contributor

Can reproduce this in a similar setup (building for github-pages). I worked around it for now is to move the s in app.html to my __layout.svelte file and wrap them in svelte:head.
Would be great to see the paths in app.html respect kit.paths.base though 👍

@Rich-Harris
Copy link
Member

As of the most recent version you can do e.g. %svelte.assets%/favicon.png in your src/app.html

@nstuyvesant
Copy link
Contributor

Seeing %svelte.head%, %svelte.body% and %svelte.assets%, are these tokens for the template documented anywhere? Are there others that can be used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature / enhancement New feature or request p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc.
Projects
None yet
5 participants