exhibit-builder-sw-precache

Generates a service worker script using sw-precache

Usage no npm install needed!

<script type="module">
  import exhibitBuilderSwPrecache from 'https://cdn.skypack.dev/exhibit-builder-sw-precache';
</script>

README

sw-precache

Exhibit.js builder plugin

Generates a service worker using the Chrome team’s sw-precache template.

$ npm install -D exhibit-builder-sw-precache

NPM version Build Status Dependency Status devDependency Status peerDependency Status

Usage

  .use('sw-precache', {cacheId: 'foo'})

This looks for cacheable files in your app, and then generates a service-worker.js that will cache those files.

This plugin should go at the end of your build sequence, after all cacheable assets’ contents have been finalized – i.e. after any preprocessors, minifiers, compressers, etc.

Options

include (string/array/function) — default: '**/*.{js,html,css,png,jpg,gif,svg}'

Chooses which files should be included in the service worker cache. Follows Exhibit’s glob convention.

filename (string) — default: 'service-worker.js'

The path for the generated service worker.

Additional options

If set, the following options are used to configure the sw-precache template:


License

MIT