Fork of parcel-plugin-workbox by Anders Dahnielson.
npm i parcel-plugin-workbox3 -D
When you build with Parcel, this plugin will automatically run generateSWString
. You can customize the settings by adding a workbox
section to your package.json
. The full configuration options can be found here. Unfortunately, parcel will not resolve files when you use navigator.serviceWorker.register
, so you must add your service worker to your parcel build target (In addition to your index
file).
package.json
{
"workbox": {
"importScripts": [
"./worker.js"
],
}
}
Note: you must include at least one script in the importScripts
property.
index.js
const pkg = require('package.json');
navigator.serviceWorker.register(`./${pkg.workbox.swDest}`);
Note: importing package.json
is generally considered insecure
- Whats different between this and the original?
Still maintained- Fixed uglify JS
- Improved configuration support
- Pass any configuration option you would normally pass to
generateSWString
- Pass any configuration option you would normally pass to
- Local workbox copy
- Reduced logging
- Why not
parcel-plugin-workbox2
?- The name was already already taken on NPM
- Why is this deprecated?
- The main reason why this was created was for Cloud CNC which as of February, 2020 is no longer using Parcel. I don't use Parcel on any other projects as of now so I decided to deprecate this package as I don't have time to maintain it.