vite-plugin-pwa
vite-plugin-pwa copied to clipboard
feat: `SvelteKit Vite Plugin` support
This PR also fix the sveltekit-pwa example.
~~supersedes #319 (ESM part)~~: ESM already included in another PR
closes #324
Deploy Preview for vite-plugin-pwa ready!
| Name | Link |
|---|---|
| Latest commit | f7927c22b89470ff1cf9acf621cf160e79163904 |
| Latest deploy log | https://app.netlify.com/sites/vite-plugin-pwa/deploys/62dc26193ed0fa0008711f03 |
| Deploy Preview | https://deploy-preview-327--vite-plugin-pwa.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
woohoo! so nice you were able to remove
pwa.js!
Still need the sequential, but yeah, finally removed.
@antfu: it seems that VitePress finally included the buildEnd hook!, we can remove it also from the docs (awaiting new release).
@benmccann @antfu I'll remove the ESM support here and make another separate PR, it can take a while to fix the sequential in Vite.
I'll include also the manifestTransform here for SvelteKit integration.
I would merge what you have here for SvelteKit support. It's a big improvement. Adding a new hook to Vite may take quite awhile, especially since I'm not even sure what API to propose yet, so I wouldn't block on it
ok, requesting review from Anthony ~~(will not work)~~
To be honest, I am not sure about having hard-code SvelteKit support directly in this plugin - it could couple with Svelte and make the maintenance harder. I would suggest this either be done on SvelteKit side, or have a higher level plugin like sveltekit-plugin-pwa or vite-plugin-sveltekit-pwa on top of this plugin. If we go with that, I think we are happy to expose the necessary APIs for it to manipulate the config, etc. /cc @benmccann
@benmccann we're going to wait https://github.com/sveltejs/kit/issues/5306 to avoid using the sequential plugin
To be honest, I am not sure about having hard-code SvelteKit support directly in this plugin - it could couple with Svelte and make the maintenance harder. I would suggest this either be done on SvelteKit side, or have a higher level plugin like sveltekit-plugin-pwa or vite-plugin-sveltekit-pwa on top of this plugin. If we go with that, I think we are happy to expose the necessary APIs for it to manipulate the config, etc. /cc @benmccann
@antfu, it looks like there are two big items here:
integrations/sveltekit/plugin.tsis dealing with the fact that SSR requires multiple builds (https://github.com/vitejs/vite/issues/5936) and we have a SvelteKit bug (https://github.com/sveltejs/kit/issues/5306). With any luck, fixing that SvelteKit issue will allow us to drop this fileintegrations/sveltekit/config.tsis primarily dealing with figuring out what URLs are in the application from layout of the prerendered (i.e. SSG-generated) files on disk. It would be nice if we could make that more generic and robust
We've had a lot of requests to create a sitemap.xml (https://github.com/sveltejs/kit/issues/1142). If we did that, then you could utilize that file, which would remove the need to understand the directory layout of SvelteKit's output and could be shared by all frameworks
@antfu this PR is ready to review, I only need to change the docs: we can include this PR in the next release (0.12.4).
It is working, but we need to await SvelteKit to fix the process.exit in the closeBundle hook: we've included a sequential plugin hook that sleeps 1sc and then call pwa closeBundle hook and finally call kit closeBundle hook.
I'll include a warning in the docs about process.exit problem.
Once SvelteKit fix the process.exit, we only need to remove the sequential plugin and we're done: the pwa build plugin will be always called after kit plugin since it has enforce post, and so, we don't need to change anything.
https://github.com/sveltejs/kit/issues/5306
@benmccann removed the sequential plugin (adapter plugin from integrations), awaiting merging https://github.com/sveltejs/kit/pull/5678 and new kit release: rn the sveltekit example stops working, we only need the new version
Maybe this can help 🤞 : https://github.com/vitejs/vite/pull/9326
included in the new integration repo