sw-precache
sw-precache copied to clipboard
Customising service worker's filename
The documentation doesn't mention a way to change the name of the generated file.
It does mention gulp, but I am using Angular 4's angular-cli to generate my assets and then run sw-precache
separately to generate the service worker.
the packages.json file consists of this command: "sw": "sw-precache --config=sw-precache-config.js --verbose"
And the sw-precache-config.js
file has the following options configured:
module.exports = { navigateFallback: '/index.html', root: '../public', staticFileGlobs: [ '../public/index.html', '../public/.js', '../public/.css', '../public/.woff2', '../public/.svg', '../public/**.ttf' ] };
I want to be able to generate custom-named service worker file each time I run npm run sw.
How can I do this?
Add this property to the config object "swFile": "public/build/custom-service-worker.js"
Thanks, that worked.
This should be added to the documentation.
@jeffposnick would you be open to an MR adding the documentation for this?