Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Rollup plugin that builds a service worker with workbox-build.

Notifications You must be signed in to change notification settings

Rainrider/rollup-plugin-workbox-build

Repository files navigation

rollup-plugin-workbox-build

Rollup plugin that builds a service worker as part of your rollup build by using workbox-build.

Shameless copy/paste of rollup-plugin-workbox by Benny Powers.

The only noteworthy change is the use of the writeBundle rollup hook instead of generateBundle, so that workbox-build can pick-up bundled assets after they have been written to disk.

Usage

Install as usual with:

npm i -D rollup-plugin-workbox-build

and use like this:

import workbox from 'rollup-plugin-workbox-build'

export default {
  input: /*...*/,
  output: /*...*/,
  plugins: [
    workbox({
      mode: 'generateSW', // or 'injectManifest'
      options: {
        swDest: 'service-worker.js',
        globDirectory: 'dist',
        // other workbox-build options depending on the mode
      },
    }
  ],
}

You can also pass your own callback for rendering workbox-build stats. It gets an object with the following properties:

  • swDest {string} - the path to the generated service worker
  • count {number} - the number of assets added for pre-caching
  • size {number} - the resulting pre-cache size in bytes

Plans

About

Rollup plugin that builds a service worker with workbox-build.

Resources

Stars

Watchers

Forks

Packages

No packages published