service-worker.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // eslint-disable-next-line no-restricted-globals
  2. // eslint-disable-next-line no-unused-expressions
  3. /* eslint-disable no-restricted-globals */
  4. /* global importScripts, workbox */
  5. /**
  6. * Welcome to your Workbox-powered service worker!
  7. *
  8. * You'll need to register this file in your web app and you should
  9. * disable HTTP caching for this file too.
  10. * See https://goo.gl/nhQhGp
  11. *
  12. * The rest of the code is auto-generated. Please don't update this file
  13. * directly; instead, make changes to your Workbox build configuration
  14. * and re-run your build process.
  15. * See https://goo.gl/2aRDsh
  16. */
  17. importScripts(
  18. "https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js",
  19. );
  20. self.addEventListener("message", (event) => {
  21. if (event.data && event.data.type === "SKIP_WAITING") {
  22. self.skipWaiting();
  23. }
  24. });
  25. workbox.core.clientsClaim();
  26. workbox.precaching.precacheAndRoute(self.__WB_MANIFEST);
  27. workbox.routing.registerNavigationRoute(
  28. workbox.precaching.getCacheKeyForURL("./index.html"),
  29. {
  30. blacklist: [/^\/_/, /\/[^/?]+\.[^/]+$/],
  31. },
  32. );
  33. // Cache relevant font files
  34. workbox.routing.registerRoute(
  35. new RegExp("/(fonts.css|.+.(ttf|woff2|otf))"),
  36. new workbox.strategies.StaleWhileRevalidate({
  37. cacheName: "fonts",
  38. plugins: [new workbox.expiration.Plugin({ maxEntries: 10 })],
  39. }),
  40. );