Skip to content

Commit 47468d6

Browse files
committed
Add service-worker.js to templates
1 parent 0cf67b8 commit 47468d6

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* eslint-disable no-restricted-globals */
2+
3+
self.addEventListener("message", event => {
4+
if (event.data && event.data.type === "SKIP_WAITING") {
5+
self.skipWaiting();
6+
}
7+
});
8+
9+
// eslint-disable-next-line no-undef
10+
workbox.core.clientsClaim();
11+
12+
/**
13+
* The workboxSW.precacheAndRoute() method efficiently caches and responds to
14+
* requests for URLs in the manifest.
15+
* See https://goo.gl/S9QRab
16+
*/
17+
self.__precacheManifest = [].concat(self.__precacheManifest || []);
18+
// eslint-disable-next-line no-undef
19+
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
20+
21+
// eslint-disable-next-line no-undef
22+
workbox.routing.registerNavigationRoute(
23+
// eslint-disable-next-line no-undef
24+
workbox.precaching.getCacheKeyForURL("/index.html"),
25+
{
26+
blacklist: [/^\/_/, /\/[^/?]+\.[^/]+$/]
27+
}
28+
);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* eslint-disable no-restricted-globals */
2+
3+
self.addEventListener("message", event => {
4+
if (event.data && event.data.type === "SKIP_WAITING") {
5+
self.skipWaiting();
6+
}
7+
});
8+
9+
// eslint-disable-next-line no-undef
10+
workbox.core.clientsClaim();
11+
12+
/**
13+
* The workboxSW.precacheAndRoute() method efficiently caches and responds to
14+
* requests for URLs in the manifest.
15+
* See https://goo.gl/S9QRab
16+
*/
17+
self.__precacheManifest = [].concat(self.__precacheManifest || []);
18+
// eslint-disable-next-line no-undef
19+
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
20+
21+
// eslint-disable-next-line no-undef
22+
workbox.routing.registerNavigationRoute(
23+
// eslint-disable-next-line no-undef
24+
workbox.precaching.getCacheKeyForURL("/index.html"),
25+
{
26+
blacklist: [/^\/_/, /\/[^/?]+\.[^/]+$/]
27+
}
28+
);

0 commit comments

Comments
 (0)