sw-precache icon indicating copy to clipboard operation
sw-precache copied to clipboard

Customising service worker's filename

Open saleemepoch opened this issue 6 years ago • 3 comments

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?

saleemepoch avatar Nov 11 '17 13:11 saleemepoch

Add this property to the config object "swFile": "public/build/custom-service-worker.js"

kamleshchandnani avatar Nov 11 '17 15:11 kamleshchandnani

Thanks, that worked.

This should be added to the documentation.

saleemepoch avatar Nov 11 '17 19:11 saleemepoch

@jeffposnick would you be open to an MR adding the documentation for this?

michaelaflores avatar Apr 03 '18 18:04 michaelaflores