2019-10-16 20:25:10 +02:00
|
|
|
/* eslint-disable no-console */
|
2019-10-16 23:27:21 +02:00
|
|
|
/* eslint-disable no-undef */
|
2019-10-16 20:25:10 +02:00
|
|
|
|
2019-10-16 23:27:21 +02:00
|
|
|
// Cache assets
|
|
|
|
workbox.routing.registerRoute(
|
|
|
|
// This regexp matches all files in precache-manifest
|
|
|
|
new RegExp('.+\\.(css|json|js|eot|svg|ttf|woff|woff2|png|html|txt)$'),
|
|
|
|
new workbox.strategies.StaleWhileRevalidate()
|
|
|
|
);
|
2019-10-16 20:25:10 +02:00
|
|
|
|
2019-10-16 23:27:21 +02:00
|
|
|
// Always send api reqeusts through the network
|
|
|
|
workbox.routing.registerRoute(
|
|
|
|
new RegExp('(\\/)?api\\/v1\\/.*$'),
|
|
|
|
new workbox.strategies.NetworkOnly()
|
|
|
|
);
|
|
|
|
|
|
|
|
// Cache everything else
|
|
|
|
workbox.routing.registerRoute(
|
|
|
|
new RegExp('.*'),
|
|
|
|
new workbox.strategies.StaleWhileRevalidate()
|
|
|
|
);
|
2019-12-18 22:30:20 +01:00
|
|
|
|
|
|
|
// This code listens for the user's confirmation to update the app.
|
|
|
|
self.addEventListener('message', (e) => {
|
|
|
|
if (!e.data) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (e.data) {
|
|
|
|
case 'skipWaiting':
|
|
|
|
self.skipWaiting();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// NOOP
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
workbox.core.clientsClaim();
|
|
|
|
// The precaching code provided by Workbox.
|
|
|
|
self.__precacheManifest = [].concat(self.__precacheManifest || []);
|
|
|
|
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
|