2021-03-24 10:07:19 +01:00
..
2021-03-24 10:07:19 +01:00
2021-02-20 09:24:33 +01:00
2021-03-05 18:51:48 +01:00
2021-03-14 23:41:10 +01:00
2021-02-20 12:16:33 +01:00
2021-02-22 18:53:19 +01:00
2021-03-21 11:48:16 +01:00

@wmr-plugins/service-worker

Allows you to add a service-worker.

Installation

yarn add @wmr-plugins/service-worker
## or
npm i --save @wmr-plugins/service-worker

Usage

We'll have to start out by adding a simple Workbox-based service worker

// public/sw.js
import { pageCache, staticResourceCache } from 'workbox-recipes';

pageCache();
staticResourceCache();

Then we use the special sw: prefix to import it and tell the plugin it's a service-worker

// public/index.js
import swURL from 'sw:./sw.js';
navigator.serviceWorker.register(swURL);

And finally we'll add the plugin to our wmr-config.

// wmr.config.js
import swPlugin from '@wmr-plugins/service-worker';

export default function (options) {
	swPlugin(options);
}