Comments (5)
I assume you're talking about dev server: we configure the entry point to avoid caching any resource, you're in dev mode and so the sw will intercept any request, any change made to the UI will not be updated.
from sveltekit.
Hey, thanks for the quick response!
I noticed that this is meant for development
only, but it seems to be affecting production
too.
Note
To clarify what I meant about "previewing", I ranpnpm build && pnpm preview
and checked the resulting local website.
Maybe it makes sense to run the following code only in development
?
+ if (import.meta.env.DEV) {
// to prevent service worker from intercepting requests in dev mode
registerRoute(new NavigationRoute(
createHandlerBoundToURL('/'),
{ allowlist },
))
+ }
from sveltekit.
@kelvindecosta then your app will not work when offline
EDIT: I mean, your service worker will work in both envs, createHandlerBoundToURL
will allow work offline (you'll need to add some logic) to avoid chrome dinossour for example... If you're using the sw only to cache assets previous code will work (you can also remove that route from the sw).
from sveltekit.
Thanks for the information!
To be completely clear, the app seems to work when in offline mode, after the above change.
Here's what I've done:
pnpm build && pnpm preview
- Visit
http://localhost:4173
in incognito mode - Clear cache (including existing service worker registration)
- Reload
- Enable network throttling
Offline
mode - Reload
The app seems to be working fine.
Note
I only see the dinosaur for a split second when I
Hard Reload
orEmpty Cache and Hard Reload
. It immediately loads the app from the service worker (confirmed in theHeaders > General
)
Even the +server.ts
routes work fine.
By strictly following the example project code, the +error.svelte
pages and +server.ts
pages never get rendered, and are always redirected to home, by the sw.
from sveltekit.
I'm having the same issue using generateSW
#44. Is there a way to get this working with generateSW
?
from sveltekit.
Related Issues (20)
- 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 6
- 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
- Please document that images that are outside of `/static` will NOT build in production HOT 2
- Workbox responses with cached data for network only requests HOT 20
- One of the glob patterns doesn't match any files HOT 6
- Please provide a minimal example
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.