vite-pwa / sveltekit

Zero-config PWA Plugin for SvelteKit
https://vite-pwa-org.netlify.app/frameworks/sveltekit
MIT License
324 stars 15 forks source link

index.js, manifest, and service worker not found #25

Closed bassjoe closed 1 year ago

bassjoe commented 1 year ago

I'm trying to create a static PWA with vite-pwa and deploy it to GitHub Pages.

Code: https://github.com/bassjoe/pwa5 Result: https://bassjoe.github.io/pwa5/

In Chrome's Developer Tools (F12), I see in the Network tab, that index.js, service worker and the manifest are not loading properly (404). The latter two work for the root /pwa5/, but not for sub-routes like /pwa5/about/ (+F5).

For the manifest I can see that the generated index.html contains the correct path to the manifest file:

<link rel="manifest" href="/pwa5/manifest.webmanifest"> (https://github.com/bassjoe/pwa5/blob/gh-pages/about/index.html)

but when I look at the effective content in the Elements tab of the Developer Tools it looks like this:

<link rel="manifest" href="./manifest.webmanifest">

For a route like /pwa5/about/ this gives /pwa5/about/manifest.webmanifest, which leads to the 404.

I can get the manifest path right by setting base: base + '/' in vite.config.js, but it looks totally wrong and in the Application/Lighthouse tabs I see that the service worker is also not working correctly.

userquin commented 1 year ago

@bassjoe I don't know what's happening with SvelketKit (some internal changes included in 1.3 version), it is broken, service worker with server assets: check this another issue https://github.com/vite-pwa/sveltekit/issues/21, we're working to fix it (it seems it is broken also in previous versions, not only from 1.3.1)

EDIT: upps wrong versions, I'll check your repo with Vite 4.0.4 and SvelteKit 1.3.0, there is a regression in Vite 4.1 and SvelteKit 1.3.1.

userquin commented 1 year ago

Same result using Vite 4.0.4 and SvelteKit 1.3.0...

bassjoe commented 1 year ago

... also with SvelteKit 1.9.3

michaelu123 commented 1 year ago

I have @vite-pwa/sveltekit 0.1.3, vite 4.0,0, @sveltejs/kit 1.0.0. With npm run build, npm run preview I see /sw.js and /manifest.webmanifest in DevTools/Application and in .svelte-kit/output/client I see sw.js, manifest.webmanifest and workbox-xxx.js. I see nothing of this in .svelte-kit/cloudflare, and in https://pianokeysdrill.pages.dev/ I get a 404 : SW registration error TypeError: Failed to register a ServiceWorker for scope ('https://pianokeysdrill.pages.dev/') with script ('https://pianokeysdrill.pages.dev/sw.js'): A bad HTTP response code (404) was received when fetching the script.

Github repo is https://github.com/michaelu123/PianoKeysDrill .

userquin commented 1 year ago

closed via #32

bassjoe commented 1 year ago

This issue is not fixed. I updated the example to latest SvelteKit 1.16.2 and still have the same problem.