@wmrjs/service-worker
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

@wmrjs/service-worker

Allows you to add a service-worker.

Installation

yarn add @wmrjs/service-worker
## or
npm i --save @wmrjs/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 '@wmrjs/service-worker';

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

Readme

Keywords

none

Package Sidebar

Install

npm i @wmrjs/service-worker

Weekly Downloads

0

Version

0.3.1

License

MIT

Unpacked Size

8.66 kB

Total Files

6

Last publish

Collaborators

  • marvinhagemeister
  • developit
  • jdecroock