Replies: 1 comment
-
Those scripts have a base prefix for their URLs as part of a remote dev environment fix #8651 kit/packages/kit/src/runtime/server/page/render.js Lines 289 to 301 in 5191e16 @benmccann is there a way to support this base path fix and the offline web archive use case that requires a relative path? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I haven't been able to make a static site using Svaltekit that is savable for offline usage. Savable means that the website can be saved using
ctrl + S
and be used offline. Chrome and Firefox handle this pretty well in most static apps.How it normally works
/script.js
,/assets/image.png
and even relative paths like./style.css
.ctrl + S
and the browser prefixes all these resources with the folder name (<PAGE_TITLE>_files
).I have made a super simple example:
index.html
script.js
When saved it creates a file
Vanilla demo.html
and a directoryVanilla demo_files
containingscript.js
.Vanilla demo.html
has the script source prefixed with./Vanilla demo_files/
.Typical working example (uses react): https://tofran.github.io/passphrase-recovery-tool/ (source).
Sveltekit
I'm using
@sveltejs/adapter-static
as documented, and have tried to setconfig.kit.paths.relative
totrue
but not all scripts are imported with a relative prefix. Notably the ones that are dynamically added to the DOM during load.I do not fully understand why, but this might be why both Chrome and Firefox cannot save the page correctly.
Also note that
config.kit.paths.base
cannot be/
nor./
, so I haven't been able to play with this setting.I have also tried to edit the key
base
of__sveltekit_<HASH>
in theindex.html
resulting from a build, but without success.Live static sveltekit examples that are not savable:
https://tofran.github.io/aws-ses-smtp-credentials/ (source)
https://sveltekit-static.onrender.com/ (source)
Vanilla example ported into Sveltekit
npm i -D @sveltejs/adapter-static
echo 'export const prerender = true;' > src/routes/+layout.js
src/routes/page.svelte
svelte.config.js
Is this a Sveltekit limitation? If so, why? Is it documented?
Environment
Node:
v18.13.0
@sveltejs/adapter-static:
2.0.1
@sveltejs/kit:
1.13.0
svelte:
3.57.0
vite:
4.2.1
Beta Was this translation helpful? Give feedback.
All reactions