I'm writing a library that contains a service worker. I'd like to create instructions for use something like this:
npm install my-lib
...
import MyLib from 'my-lib'
...
MyLib.init();
And in the init()
function I need to register the service worker.
I'd like the actual service worker file to be in my library, and it would be nice if I didn't have to ask the client to change their webpack.config.js
file.
Is there a way for my library to indicate that the service worker file should be copied to the server with no processing so that it can be registered?
I was thinking my library would have a structure like:
public
sw.js
src
etc.js
index.js
package.json
Thanks for any help you can give. Most of the info I've found concerns the PWA service worker that caches assets and I don't see much info on just simple, generic service workers.