From 0f143fd2502d2833892bb96be93db602c60ea01e Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Wed, 15 Nov 2017 11:11:15 -0500 Subject: [PATCH] Add a localhost-only log message pointing folks to the PWA docs. --- .../react-scripts/template/src/registerServiceWorker.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/react-scripts/template/src/registerServiceWorker.js b/packages/react-scripts/template/src/registerServiceWorker.js index 12542ba2295..a3e6c0cfc10 100644 --- a/packages/react-scripts/template/src/registerServiceWorker.js +++ b/packages/react-scripts/template/src/registerServiceWorker.js @@ -35,6 +35,15 @@ export default function register() { if (isLocalhost) { // This is running on localhost. Lets check if a service worker still exists or not. checkValidServiceWorker(swUrl); + + // Add some additional logging to localhost, pointing developers to the + // service worker/PWA documentation. + navigator.serviceWorker.ready.then(() => { + console.log( + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ); + }); } else { // Is not local host. Just register service worker registerValidSW(swUrl);