A plugin for Parcel to generate a service worker with Workbox.
You can either install by running yarn (recommended)
yarn add parcel-plugin-workbox --dev
or use npm
npm install parcel-plugin-workbox --save-dev
When you build resources with Parcel, the plugin will generate a service worker sw.js
and insert it into your project's index.html
entry file.
You can customize the settings by adding a workbox
section to your package.json
.
"workbox": {
importScripts: ['./worker.js'], // scripts to import into `sw.js`
globDirectory: './dist', // directory to cache (usually output dir)
globPatterns: [ // file types to include
'**/*.{css,html,gif,js,jpg,png,svg,webp}'
}
Workbox requires at least one import script to be defined. By default, a worker.js
file, where you can write the logic for your service worker, will be read from your project's root directory and imported into sw.js
unless you change this setting. Additionally, a CDN version of Google Workbox is imported automatically.
We use SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the MIT License - see the LICENSE.md file for details.