I used to use sw-toolbox
for management of my service worker - small, simple, effective. Now that Google have released Workbox SW
(which replaces sw-toolbox and sw-precache) I need to migrate, but am battling to find:
a) single .js dependency for Workbox that I can include in my project
b) a custom build tool to build a single .js dependency
c) a way to include the Workbox build in my project build
Am I going about this the wrong way?
Two useful references:
http://leruplund.dk/2017/04/15/setting-up-asp-net-core-in-visual-studio-2017-with-npm-webpack-and-typescript-part-i/
and
https://workboxjs.org/how_tos/workbox-cli.html
Or just follow the 4 steps below
Step 1: Install Node.js from https://nodejs.org/en/download/current/
Step 2: Initialize NPM on your project by opening command prompt on your project root and running the command
npm init -y
Step 3: From the same location at your command prompt, install Workbox with NPM by running the command
npm install workbox-cli --global
Step 4: Generate a service worker by running the command
workbox-cli generate:sw
Having fiddled around a some hours, I was disappointed to note that the Workbox base dependency is 3x bigger than sw-toolbox - so, if size is critical to your project (which it often is for 3rd world market) then keep this in mind (sw-toolbox is 16kb, workbox is 48kb)
sw-toolbox works just fine for me at the moment, so I'm going to go back to it until I can work out how to get the size of Workbox a bit smaller.
However, I hope this helps someone else in the meantime :)