custom-service-worker.js 858 B

123456789101112131415161718192021222324252627282930
  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 { precacheAndRoute, cleanupOutdatedCaches, createHandlerBoundToURL } from 'workbox-precaching'
  9. import { registerRoute, NavigationRoute } from 'workbox-routing'
  10. self.skipWaiting()
  11. clientsClaim()
  12. // Use with precache injection
  13. precacheAndRoute(self.__WB_MANIFEST)
  14. cleanupOutdatedCaches()
  15. // Non-SSR fallback to index.html
  16. // Production SSR fallback to offline.html (except for dev)
  17. if (process.env.MODE !== 'ssr' || process.env.PROD) {
  18. registerRoute(
  19. new NavigationRoute(
  20. createHandlerBoundToURL(process.env.PWA_FALLBACK_HTML),
  21. { denylist: [/sw\.js$/, /workbox-(.)*\.js$/] }
  22. )
  23. )
  24. }