- 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');

  }
This commit is contained in:
Paolo Arena
2019-01-31 13:52:52 +01:00
parent c3739e2b32
commit fa7247a338
16 changed files with 128 additions and 59 deletions

13
workbox-config.js Normal file
View File

@@ -0,0 +1,13 @@
module.exports = {
"globDirectory": "dist/pwa-mat/",
"globPatterns": [
"**/*.{css,woff2,woff,svg,html,js,json,ico}"
// "src/images/*.{jpg,png}"
],
// "swSrc": "dist/pwa-mat/src-sw.js",
"swDest": "dist/pwa-mat/service-worker.js",
"globIgnores": [
"../workbox-config.js",
"help/**"
],
};