Created
August 7, 2018 00:11
-
-
Save kevinah95/2b84ba5c92fd21e2b3b2a4ee0009b160 to your computer and use it in GitHub Desktop.
custom-sw.js for Using Workbox with Create React App (Without Ejecting) Medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // See https://developers.google.com/web/tools/workbox/guides/configure-workbox | |
| workbox.core.setLogLevel(workbox.core.LOG_LEVELS.debug); | |
| self.addEventListener('install', event => event.waitUntil(self.skipWaiting())); | |
| self.addEventListener('activate', event => event.waitUntil(self.clients.claim())); | |
| // We need this in Webpack plugin (refer to swSrc option): https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin#full_injectmanifest_config | |
| workbox.precaching.precacheAndRoute(self.__precacheManifest); | |
| // app-shell | |
| workbox.routing.registerRoute("/", workbox.strategies.networkFirst()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment