@io-arc/task-service-worker

Create a Service Worker file.
Execute src/sw.js if it exists.
It is created using generateSW of WorkBox.

* There's no watch mode.

Usage#

$ npm i -D @io-arc/task-service-worker
$ ia-sw [options]

Or

package.json
{
"scripts": {
"service-worker": "ia-sw",
"service-worker-template": "ia-sw --template"
}
}
$ npm run service-worker
$ npm run serivce-worker-template

Options#

--template, -t#

Create a template to sw.js.

sw.js#

The minimum configuration required for execution.

src/sw.js
module.exports = {
manifest: {}
}

The globDirectory and swDest properties, which are required by WorkBox, are ignored even if they are specified because they are generated automatically.

Changing output file name#

Default output file name is sw.js, but you can change the file name.

src/sw.js
module.exports = {
filename: 'foo.js',
manifest: {}
}
// output 'path/dist/foo.js'

Manifest options#

Take a look at WorkBox#generateSW

example

src/sw.js
module.exports = {
manifest: {
ignoreURLParametersMatching: [/^utm_/],
directoryIndex: 'index.html',
globFollow: true,
globIgnores: ['node_modules/**/*'],
sourcemap: false
}
}