Comments (5)
@AKuederle try to configure scope pwa option with the base path configured in kit config.
from sveltekit.
Thank you very much for the fast response. The scope
option didn't help, but setting the base
option in the SvelteKitPWA
plugin seems to solve the above issue. This way the manifest and the assets seemed to be served correctly.
For some reason I thought, that the default for this setting (vite.base
) would have been already set by sveltekit itself. But it seems not to be the case.
However, even with these settings, offline access does not seem to work. This seems to be independent of the base-path though. So it is likely a different issue. But basically it seems like the service worker caches everything BUT the actual index.html file generated during build does not seem to be cached by the service worker, resulting in non-prechached-url
error on a repeated app load.
from sveltekit.
Ok I solved the issue! But maybe this is interesting for others:
I forgot to mark my page as prerenderable, (export const prerender = true
in +layout.ts
) and instead set a fallback page in the adapter static configuration. This allows the static build to succeed, but because the page is not marked as prerenderable, it is not added to the service worker cache.
I don't know if this is the intended interaction, but making sure to mark all my pages to be pre-rendered solved my issue.
@userquin Do you think this is something worth adding to the documentation somewhere? I am happy to contribute a paragraph.
from sveltekit.
@AKuederle you can send a PR to docs repo, to use precaching we need at least 1 html page, so you need at least 1 page with prerender = true
: check this PR as an example to use PWA plugin without precaching (not kit releated)
On kit, if you're not using precaching, you can use kit service worker implementation instead using this integration.
from sveltekit.
@userquin This 100% should be in docs. I just set it up with "Zero Config", no SvelteKitPWA() settings, which does not work; it shows a warning when no document is prerendered e.g.
warnings
One of the glob patterns doesn't match any files. Please remove or fix the following: {
"globDirectory": "C:/Users/andys-pc/GitHub/MyStuff/Someplice/.svelte-kit/output",
"globPattern": "prerendered/**/*.html",
"globIgnores": [
"**/node_modules/**/*",
"server/sw.js",
"server/workbox-*.js"
]
}
but it is not documented that this is required. And in fact in my simple Sveltekit app, even prerendering a page my PWA does not show up in browser. The requirement of a service worker config and/or vite.base
and/or prerender
is not obvious... docs make this seem like zero-config should work.
from sveltekit.
Related Issues (20)
- Example project renders home page on missing routes HOT 5
- Failed to load config v0.2.1 HOT 3
- Add a test
- Can't get @vite-pwa/sveltekit to work out-of-the-box HOT 14
- Having an issue with ssr = false HOT 8
- Issues with SPA HOT 1
- Inject Register script or inline has no effect on output HTML. HOT 6
- [Info] Cloudflare Adapter Routes misses vite-pwa HOT 1
- Cannot find module 'virtual:pwa-info' or its corresponding type declarations HOT 26
- Importing 'virtual:pwa-register' causes bug on build HOT 3
- Make client Javascript work offline HOT 2
- Deprecated packages HOT 2
- Uncaught (in promise) non-precached-url: non-precached-url :: [{"url":"/"}] HOT 13
- Navigating to SvelteKit error page after a new build causes infinite page reload loop HOT 5
- InjectManifest `The 'swSrc' file can't be read. ENOENT: no such file or directory` error on Gitlab CI HOT 5
- Uncaught ReferenceError: process is not defined for injectManifest HOT 1
- Error: [InjectManifest] 'plugins' property is not expected to be here. HOT 1
- Support Node v20 HOT 1
- Uncaught SyntaxError: Unexpected token 'export' HOT 3
- `_app/version.json` should be included in sw precache manifest
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sveltekit.