Files
freeplanet/src-pwa/register-service-worker.js
Paolo Arena fa7247a338 - Activated Workbox precache PWA !
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-sw.js');

  if (!workbox) {
    workbox = new self.WorkboxSW();
  }

  if (workbox) {
    workbox.core.setCacheNameDetails({prefix: "freeplanet"});

    /**
     * The workboxSW.precacheAndRoute() method efficiently caches and responds to
     * requests for URLs in the manifest.
     * See https://goo.gl/S9QRab
     */
    self.__precacheManifest = [].concat(self.__precacheManifest || []);
    workbox.precaching.suppressWarnings();
    workbox.precaching.precacheAndRoute(self.__precacheManifest, {});

    workbox.routing.registerRoute(/^http/, workbox.strategies.networkFirst(), 'GET');

  }
2019-01-31 13:52:52 +01:00

41 lines
1.3 KiB
JavaScript

/*
* This file is picked up by the build system only
* when building for PRODUCTION
*/
import {register} from 'register-service-worker'
register(process.env.SERVICE_WORKER_FILE, {
ready() {
console.log('READY::: App is being served from cache by a service worker.')
},
registered(registration) { // registration -> a ServiceWorkerRegistration instance
console.log('REGISTERED::: !!!', process.env.SERVICE_WORKER_FILE)
},
cached(registration) { // registration -> a ServiceWorkerRegistration instance
console.log('CACHED::: Content has been cached for offline use.')
},
updatefound(registration) { // registration -> a ServiceWorkerRegistration instance
console.log('UPDATEFOUND::: New content is downloading.')
},
updated(registration) { // registration -> a ServiceWorkerRegistration instance
console.log('New content is available; please refresh.')
},
offline() {
console.log('No internet connection found. App is running in offline mode.')
},
error(err) {
console.error('Error during service worker registration:', err)
},
}
);
// ServiceWorkerRegistration: https://developer.mozilla.org/en-uk/docs/Web/API/ServiceWorkerRegistration
// "build": "quasar build -m pwa && workbox generateSW workbox-config.js",