-
-
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
Could not to use relative asset URL #8342
Comments
Please don't write N/A in the reproduction section. SvelteKit does use relative paths by default. The exceptions are a) you've specified an external asset path or b) you're rendering a fallback page: kit/packages/kit/src/runtime/server/page/render.js Lines 144 to 158 in 4f27b81
I assume the latter applies in your case, but without a reproduction I'm just speculating. |
Updated the reproduction section.
You guessed it right. My use case is to package the code into an Electron app. That's why I used |
For an Electron app, I don't think you need to use fallback. The purpose of fallbacks is so that if you use a static webserver and the user hits a path like But in an Electron app you have a lot more control — you should be able to serve a regular |
Rich-Harris, I tried. This time I wanted a clean reproduction of this issue to nail it down to the dot. Please see the updated Reproduction section. This time no Electron, I just focused on getting |
If you're trying to use Electron, you might find some of the existing resources from around the web to be helpful: |
Solved by moving |
Describe the bug
For my use case, I need the asset path to be relative (without a leading slash).
Why? In case of a Chrome Extension or a bundled Desktop App like Electron, the assets need to be loaded without serving from a web server. Thus requires the paths to be relative.
Currently,
%sveltekit.head%
produces absolute<link ...>
such as:I need these links to be:
Just without the leading slashes.
Reproduction
Create a new SvelteKit app using
npm create
(as mentioned in the Getting Started page):npm create svelte@latest my-app cd my-app npm install
Install
adapter-static
:Edit
svelte.config.js
:Then added a new file:
src/routes/+layout.ts
:That worked! But if I use
+layout.svelte
instead of+layout.ts
:src/routes/+layout.svelte
:And then run
npm run build
, it complains that all routes must be fully prerenderable.Logs
System Info
npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
Severity
Serious, and I could not work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: