-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fallback file does not exist in injected manifest (for SPA app) #94
Comments
can you provide a minimal reproduction? |
I quickly created a mini prototype that has exactly the same issue here: https://github.com/fkrauthan/sveltekit-pwa-issue The code for that example was created with a fresh sveltekit creation using |
app.html is not a page, it is just the kit html template to render content, you need to prerender a page to be used as fallback, check the examples in the repo, using the root page (+page.ts) |
But based on the documentation that is exactly what I suppose to be using. https://vite-pwa-org.netlify.app/frameworks/sveltekit#sveltekit-and-adapters says I should set |
Based on the SvelteKit documentation (https://svelte.dev/docs/kit/single-page-apps#Usage) the fallback page generated html is actually special in regards of using absolute paths for all imports. It is also the HTML we should be configuring for our web hosters to serve in case a real file was not found on disk. |
To use offline support you need:
So, you need to deal with that, maybe you can use 2 different pages for adapter and sw offline fallback. |
I'm going check what's the build output in your reproduction... |
The big issue I see is that the generated |
Yeah, the app.html is on build folder but not generated by kit, I guess it is the adapter and so the kit pwa plugin cannot do anything since the build folder is missing when the plugin builds the sw. No idea who is generating the app.html, kit or the adapter. /cc @benmccann |
It looks like the adapter-static is triggering the generation here https://github.com/sveltejs/kit/blob/9a4a41170ab3e17f947eb4a67944958b22da4236/packages/adapter-static/index.js#L69 And this seem to be the way sveltekit internally generates the file: https://github.com/sveltejs/kit/blob/9a4a41170ab3e17f947eb4a67944958b22da4236/packages/kit/src/core/adapt/builder.js#L156 Not sure if it helps. But somehow that generated file need to be embedded into the manifest of your plugin. Otherwise at least with the current sveltekit version I don't think it will be possible to have an fully offline ready app. |
If you request that html page, what's the response from the server? requesting |
At least based on how I deployed my page to firebase hosting, I can request |
ok, so the problem is about using kit to generate an SPA (csr: client side rendered): https://svelte.dev/docs/kit/single-page-apps |
The problem is that kit generated everything for an spa. But the pwa plugin is not able to see (and include into manifest) one critical file which in return means my app is not fully functional offline. |
I'm trying to add the app.html to the sw manifest... |
Preparing PR to your reproduction... |
PR in the repo: fkrauthan/sveltekit-pwa-issue#1 The problem, Sveltekit SPA adapter running at the end of the process, I need to check why this behavior (maybe we can change it): |
Oh nice. Is the plan to have that workaround be part of this plugin in the near future? Or will this be always a case where users will have to re-implement this workaround? |
Btw re using |
I'm going to add Replace |
@fkrauthan can you check fkrauthan/sveltekit-pwa-issue#2 ? In your case, you can use in your real app: spa: {
fallbackMapping: '/app' // or just 'app'
} Use the kit pwa version from the PR, once tested I can release a new patch version. |
I assume you mean setting
seem to work for me with your custom version. In general I wonder if just setting |
oh, so we can remove the You can also use: kit: {
adapterFallback: "app.html",
spa: {
fallbackMapping: 'app',
}
}, |
@fkrauthan kit pwa v0.6.7 released |
I am currently creating a SPA using Svelte 5, SvelteKit 2 and Vite 6. For the SvelteKitPWA plugin I use the
injectManifest
strategy and I configured my fallback(for sveltekit adapater static) to beapp.html
.When I build my project I see the
app.html
file correctly in thebuild
folder. However when I inspect the injected data in my service worker the entry forapp.html
is missing (as a matter of fact not even anapp
entry is there.I looked a bit into this plugins code and it seems like you guys are expecting a
fallback.html
inside theprerender/pages
folder (inside.svelte-kit
). However that folder does not contain a fallback.html file (nor does it contain anapp.html
file) the only files it contains are the once from my actual pre-rendered pages.Not sure if that is some type of recent change in how Vite/SvelteKit works or am I missing some setup?
The text was updated successfully, but these errors were encountered: