Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
service-worker update
Browse files Browse the repository at this point in the history
gurumaxi committed May 19, 2024

Verified

This commit was signed with the committer’s verified signature.
dmitryax Dmitrii Anoshin
1 parent f08efce commit 7c89431
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
@@ -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",
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 7c89431

Please sign in to comment.