How to Build WorkBox ServiceWorker with Meteor?

We have fetch handlers that caches our files i.e. workbox.routing.registerRoute

workbox-navigation-preload should be workbox.navigationPreload (have not used this though)

@ vikr00001 why do you want to do it via Workbox specifically?!
Workbox, I believe, is just a wrapper around fetch and I am curious of your specific need for it.

Here is an example of plain JS service worker: Meteor-PWA-Explained/3_Service_workers.md at master · activitree/Meteor-PWA-Explained · GitHub

I haven’t studied what goes on in service workers yet-- I’m just trying to pick one and plug it in. :slight_smile: So on that basis of missing knowledge ( :slight_smile: ), I thought it would be a solid pick to go with one from Google. Once I learned from @rjdavid in his post above about ImportScripts(), it was easy to get it working.

I’d be very interested in anything I can learn from you on this topic.

We also had our custom service worker before with all the required boilerplate code. After using workbox

  1. Our service worker code is shorter (less than 20% of what it was)
  2. Easier to understand (easy to pick up by other developers from the team) and therefore easier to maintain
  3. We gain best practices and updates as workbox is updated (without us doing extra work)

The same reasons why we use any npm or meteor packages

1 Like