Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

parcel-plugin-sw-precache

1.1.2 • Public • Published

parcel-plugin-sw-precache

npm version

A Parcel plugin for generating a service worker that precaches resources.

Usage(Install)

npm install --save-dev parcel-plugin-sw-precache

Configurations

You DON'T have to configure anything to get it work. It just works as you expected after you installed.

Every time you build resources with Parcel, it will generate a service-worker.js file for you.

Internally it is using sw-precache

If you want to configure sw-precache, you can supply the configs by adding them in your package.json within the key sw-precache. See all available options at: https://github.com/GoogleChromeLabs/sw-precache#options-parameter

Additionally this plugin have the option "additionalCodeFile" if you want to add anything to your service-worker.js (for example a new event-handler). Add a filename relative to the entrypoint specified to Parcel.

For example:

{
  "name": "my-project",
  "version": "0.1.0",
  ...

  // my sw-precache configs
  "sw-precache": {
    "maximumFileSizeToCacheInBytes": 10485760,
    "additionalCodeFile": "addSome.js"
  }
}

Note: only files with the following extensions will be added to the precache : js, html, css, png, jpg, gif, svg, eot, ttf, woff, woff2, ogg, wav, mp3, wasm, webp, pdf

License

MIT

Keywords

Install

npm i parcel-plugin-sw-precache

DownloadsWeekly Downloads

251

Version

1.1.2

License

MIT

Unpacked Size

6.25 kB

Total Files

4

Last publish

Collaborators

  • avatar