mischnic / parcel-plugin-sw-cache

📦👷 Parcel plugin for caching using a service worker
https://npm.im/parcel-plugin-sw-cache
MIT License
47 stars 6 forks source link

How to pre-process the service worker with Parcel? #22

Open jtojnar opened 5 years ago

jtojnar commented 5 years ago

I have some imports, as well as some other modern JavaScript features in the ServiceWorker but they are not processed by Parcel/Babel – the generated file still contains:

import {skipWaiting} from 'workbox-core';
import {precacheAndRoute} from 'workbox-routing';

How to make Parcel to process the file?

I am using the following config:

  "cache": {
    "strategy": "inject",
    "swSrc": "./js/selfoss-sw-offline.js",
    "templatedURLs": {},
    "swDest": "service-worker.js"
  }
mischnic commented 5 years ago

That is unfortunately not possible with this plugin (you need to do an extra buildstep beforehand)