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

files in $service-worker should contain prerendered files #2271

Closed
frederikhors opened this issue Aug 23, 2021 · 6 comments · Fixed by #4192
Closed

files in $service-worker should contain prerendered files #2271

frederikhors opened this issue Aug 23, 2021 · 6 comments · Fixed by #4192
Labels
service worker Stuff related to service workers

Comments

@frederikhors
Copy link
Contributor

frederikhors commented Aug 23, 2021

Using adapter-static and the code:

import { files } from '$service-worker';

I expect to find also the <NAME>.html fallback file listed in files.

Am I wrong?

@ignatiusmb
Copy link
Member

Please provide a complete and minimal reproducible example of what happen and should've happen.

@ignatiusmb ignatiusmb added pending clarification service worker Stuff related to service workers labels Aug 23, 2021
@Mlocik97
Copy link
Contributor

this is specific for adapter, so it's not good if it's provided by $service-worker, why You don't simply add manually that file to it? It's just one line of code.

@benmccann benmccann changed the title files in $service-worker should contain the fallback html file using adapter-static files in $service-worker should contain prerendered files Aug 24, 2021
@benmccann
Copy link
Member

benmccann commented Aug 24, 2021

For fallback we can add just the one. For prerendered files there might be too many to do this. We'd have to have the adapter generate the manifest after prerendering I guess? Or maybe we can somehow do SSG during Vite build, which I think vitepress might do

@userquin
Copy link
Contributor

userquin commented Aug 26, 2021

@frederikhors The problem is that any adapter used is called after svelte finish build process, so calling/building the service worker module cannot have those files.

@benmccann vitepress right now has not pwa support: you can see how I regenerate the vite-plugin-pwa docs using vitepress and executing again the pwa build process for build it (on build script on docs package.json file), that is, after vitepress build finish.

I have a branch on my fork of vitepress with the build module using the vite-plugin-pwa api like the svelte kit one (on my fork):

@userquin
Copy link
Contributor

userquin commented Aug 26, 2021

@ignatiusmb you can build and preview the https://github.com/svelte-society/sveltesociety.dev: before building it, just add a service worker file and log the files entry from service worker module.

You can see the expected output on this branch on my fork of svelte-society, using the vite-plugin-pwa, just build the project and see sw.js generated file from vite-plugin-pwa: https://github.com/userquin/sveltesociety.dev.

On following screenshot, all these pages (there are a lot more) are missing from the service worker module (and for that reason, apps using service worker module cannot run on offline: if you preview my master branch fork, all pages will work on offline).

imagen

@benmccann
Copy link
Member

SvelteKit's own service worker should contain prerendered files now. Unfortunately, it still doesn't happen early enough in the build process that plugins like vite-plugin-pwa could pick them up

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

Successfully merging a pull request may close this issue.

5 participants