parcel-plugin-inject-manifest-service-worker

Injects the files outputted from a Parcel build as a workbox precache compliant array

Usage no npm install needed!

<script type="module">
  import parcelPluginInjectManifestServiceWorker from 'https://cdn.skypack.dev/parcel-plugin-inject-manifest-service-worker';
</script>

README

Parcel and Precaching with a Custom Service Worker

CI code style: prettier Commitizen friendly npm version

You've a custom service worker and want to support precaching using workbox. This will inject the files outputted from a Parcel build as a workbox precache compliant array.

Installation

Begin by install the package as a dependency

npm i parcel-plugin-inject-manifest-service-worker

Usage

Insert SERVICE_WORKER_MANIFEST_ENTRIES wherever you want a workbox precache compliant array

precacheAndRoute(SERVICE_WORKER_MANIFEST_ENTRIES);

If you're using TS, add the following to avoid errors

/// <reference path="../../node_modules/parcel-plugin-inject-manifest-service-worker/index.d.ts" />

Build using Parcel

Configuration

There currently is no way to configure this plugin.

The current configuration will look for a service-worker.js file in the Parcel's output folder. This means that your service worker file must be named service-worker.js or service-worker.ts and be located as an immediate child of the output folder.

The generated manifest will provide revisions for any files matching:

  • *.html