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

Local source for workboxSW #2

Closed goofblob closed 6 years ago

goofblob commented 6 years ago

Is it possible to configure the plugin to load workbox-sw.js from a local source, rather than the Google CDN?

If not, it should be.

Say, the plug-in installs workbox-sw as a npm dependency, and at Parcel build time, it copies the production version of workbox-sw.js from its local node_modules folder, places it in /dist/ and sw.js does only

importScript('workbox-sw.js')

For one of my projects, getting workbox from the Google CDN takes longer than not using a service worker at all.

Thanks.

mischnic commented 6 years ago

This is already possible (provided by workbox):

Just add "importWorkboxFrom": "local" to your package.json:

{
  "name": "MyApp",
  "cache": {
    "importWorkboxFrom": "local"
  }
}

(The documentation at https://developers.google.com/web/tools/workbox/reference-docs/prerelease/module-workbox-build#.Configuration is misleading.)

bildschirmfoto 2018-01-31 um 21 44 53

goofblob commented 6 years ago

Amazing!

Thanks.