-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Service Worker registration * Add sw-precache support to npm run scripts * Add SW runtime caching and pre-cache config * gitignore: ignore sw-toolbox and generated sw script * Include empty SW script for local testing * Improve Service Worker registration script * Drop explicit registration update.
- Loading branch information
1 parent
17443dc
commit f33eee3
Showing
6 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/public/build | ||
/node_modules | ||
/public/sw-toolbox.js |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// global.toolbox is defined in a different script, sw-toolbox.js, which is part of the | ||
// https://github.com/GoogleChrome/sw-toolbox project. | ||
// That sw-toolbox.js script must be executed first, so it needs to be listed before this in the | ||
// importScripts() call that the parent service worker makes. | ||
(function(global) { | ||
'use strict' | ||
|
||
// See https://github.com/GoogleChrome/sw-toolbox/blob/6e8242dc328d1f1cfba624269653724b26fa94f1/README.md#toolboxroutergeturlpattern-handler-options | ||
// and https://github.com/GoogleChrome/sw-toolbox/blob/6e8242dc328d1f1cfba624269653724b26fa94f1/README.md#toolboxfastest | ||
// for more details on how this handler is defined and what the toolbox.fastest strategy does. | ||
global.toolbox.router.get('/(.*)', global.toolbox.fastest, { | ||
origin: /\.(?:googleapis|gstatic|firebaseio)\.com$/ | ||
}) | ||
global.toolbox.router.get('/(.+)', global.toolbox.fastest, { | ||
origin: 'https://hacker-news.firebaseio.com' | ||
}) | ||
global.toolbox.router.get('/(.+)', global.toolbox.fastest, { | ||
origin: 'https://s-usc1c-nss-136.firebaseio.com' | ||
}) | ||
})(self) | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This file is intentionally without code. | ||
// It's present so that service worker registration will work when serving from the 'public' directory. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"importScripts": [ | ||
"sw-toolbox.js", | ||
"runtime-caching.js" | ||
], | ||
"stripPrefix": "public/", | ||
"verbose": true | ||
} |