-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
39 lines (34 loc) · 1.17 KB
/
sw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
importScripts('./workbox/workbox-v7.1.0/workbox-sw.js');
workbox.setConfig({
modulePathPrefix: './workbox/workbox-v7.1.0/',
});
const EXTERNAL_LIBS = [
"https://docs.opencv.org/4.x/opencv.js",
"https://unpkg.com/[email protected]/dist/umd/comlink.js",
]
workbox.routing.registerRoute(
({request}) => {
return request.destination === 'document' || EXTERNAL_LIBS.includes(request.url)
},
new workbox.strategies.NetworkFirst()
);
// NOTE: Don't touch the line below! It'll be replaced by workbox-cli to include data generated
// from workbox-config.js
workbox.precaching.precacheAndRoute(self.__WB_MANIFEST)
workbox.routing.registerRoute(
new workbox.routing.NavigationRoute(
workbox.precaching.createHandlerBoundToURL("./index.html")
),
new workbox.strategies.NetworkFirst()
)
// The Background Sync plugin is used to queue the bug reports
const bgSyncPlugin = new workbox.backgroundSync.BackgroundSyncPlugin('bugReports', {
maxRetentionTime: 3 * 24 * 60, // we'll keep requests for up to 3 days
});
workbox.routing.registerRoute(
/\/bugreport/,
new workbox.strategies.NetworkOnly({
plugins: [bgSyncPlugin],
}),
'POST'
);