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

replace %svelte.assets% with relative path #3234

Merged
merged 4 commits into from
Jan 7, 2022
Merged

replace %svelte.assets% with relative path #3234

merged 4 commits into from
Jan 7, 2022

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Jan 7, 2022

Fixes #2697, supersedes #3088. Replaces %svelte.assets% in src/app.html with a relative path to the root (or to paths.assets in production, if specified).

In other words this...

<link rel="icon" type="image/png" href="%svelte.assets%/favicon.png" />

...will work regardless of whether paths.assets is set, and will also work if you've set paths.base (or, in future, if we implement dynamic basepaths somehow) because a page like /custom-basepath/foo/bar/baz will link to ../../favicon.png, which resolves to /custom-basepath/favicon.png. It will still work if trailingSlash is "always" .

(Note that there's currently a bug around paths.base — static assets aren't served from there in dev mode. Needs fixing separately.)

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Jan 7, 2022

🦋 Changeset detected

Latest commit: a854e31

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@sveltejs/kit Patch
create-svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Jan 7, 2022

❌ Deploy Preview for kit-demo failed.

🔨 Explore the source changes: a854e31

🔍 Inspect the deploy log: https://app.netlify.com/sites/kit-demo/deploys/61d87da58e8a7e00079aedb5

@Conduitry
Copy link
Member

Also adjacent: #3231 and #3232

@Rich-Harris
Copy link
Member Author

The deployments are failing because they're trying to build with the most recent released version of Kit, which doesn't know how to handle %svelte.assets% and is therefore resulting in a malformed URI error when prerendering. We can safely ignore

@Conduitry
Copy link
Member

Conduitry commented Jan 7, 2022

Should this PR be marked as resolving #3231 now? There should be a changeset added for the create-svelte change in any case.

I didn't look closely at what was happening in #3232.

@Rich-Harris Rich-Harris linked an issue Jan 7, 2022 that may be closed by this pull request
@Rich-Harris
Copy link
Member Author

It should, yeah. I need to look into #3232

@dreitzner
Copy link
Contributor

@Rich-Harris should I port the relevant docs over from #3088 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Favicon does not use kit paths Generated URLs are inconsistent to the basepath with adapter-static
3 participants