Forked from davidgilbertson/sw-precache-config.js
Last active
April 14, 2018 22:40
-
-
Save fabriciofmsilva/c99f2f052d6a56a52a09fbf66ee144ff to your computer and use it in GitHub Desktop.
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
swPrecache.write(path.resolve(__dirname, `../public/service-worker.js`), { | |
cacheId: `know-it-all`, | |
filename: `service-worker.js`, | |
stripPrefix: `public/`, | |
staticFileGlobs: [ | |
`public/app.*.js`, // don't include the polyfills version | |
`public/*.{html,ico,json,png}`, | |
], | |
dontCacheBustUrlsMatching: [ | |
/\.(js|json)$/, // I'm cache busting js and json files myself | |
], | |
skipWaiting: true, | |
}, (err) => { | |
if (err) { | |
reject(err); | |
} else { | |
resolve(); | |
} | |
}); |
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
if (`serviceWorker` in navigator) { | |
navigator.serviceWorker.register(`service-worker.js`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment