Skip to content

Commit

Permalink
service-worker update
Browse files Browse the repository at this point in the history
  • Loading branch information
gurumaxi committed May 19, 2024
1 parent f08efce commit 59065f6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
14 changes: 12 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"tslib": "2.6.2",
"typescript": "5.4.5",
"vite": "5.2.11",
"workbox-routing": "7.1.0",
"workbox-strategies": "7.1.0"
"workbox-precaching": "7.1.0"
},
"dependencies": {
"@neodrag/svelte": "2.0.6",
Expand Down
23 changes: 17 additions & 6 deletions src/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { registerRoute } from 'workbox-routing';
import { NetworkFirst } from 'workbox-strategies';
import { build, files, prerendered, version } from '$service-worker';
import { precacheAndRoute } from 'workbox-precaching';

self.__WB_DISABLE_DEV_LOGS = true;

registerRoute(
({ url }) => url,
new NetworkFirst()
);
const precacheList = [
...build,
...files,
...prerendered,
].map(s => ({
url: s,
revision: version,
}));

precacheAndRoute(precacheList);

// Force the new service worker to take control immediately
self.addEventListener('install', () => {
self.skipWaiting();
});

0 comments on commit 59065f6

Please sign in to comment.