custom-service-worker.js 926 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* eslint-env serviceworker */
  2. /*
  3. * This file (which will be your service worker)
  4. * is picked up by the build system ONLY if
  5. * quasar.config.js > pwa > workboxMode is set to "injectManifest"
  6. */
  7. import { clientsClaim } from 'workbox-core'
  8. import {
  9. precacheAndRoute,
  10. cleanupOutdatedCaches,
  11. createHandlerBoundToURL
  12. } from 'workbox-precaching'
  13. import { registerRoute, NavigationRoute } from 'workbox-routing'
  14. self.skipWaiting()
  15. clientsClaim()
  16. // Use with precache injection
  17. precacheAndRoute(self.__WB_MANIFEST)
  18. cleanupOutdatedCaches()
  19. // Non-SSR fallback to index.html
  20. // Production SSR fallback to offline.html (except for dev)
  21. if (process.env.MODE !== 'ssr' || process.env.PROD) {
  22. registerRoute(
  23. new NavigationRoute(
  24. createHandlerBoundToURL(process.env.PWA_FALLBACK_HTML),
  25. {
  26. denylist: [
  27. /api$/,
  28. /sw\.js$/,
  29. /workbox-(.)*\.js$/
  30. ]
  31. }
  32. )
  33. )
  34. }