Search code examples
workboxworkbox-webpack-plugin

Change the url for the workbox runtime


As of v5, workbox generates a runtime bundle which is very useful. I was not able to find a way to specify where the bundle should be. by default it is next to the service worker file, but we need it to be on a CDN. Is this possible?


Solution

  • Sorry, that's not configurable in v5.

    You don't mention why you need it to be on the CDN—if that's not a hard requirement, I'd suggest just keeping it alongside your service worker. You have control over how frequently imported scripts are checked for updates if you're concerned about QPS.

    Alternatively, you can set inlineWorkboxRuntime: true and you'll end up with a single file that contains both your service worker logic and the Workbox runtime code. If for some reason deploying two files is a problem, but one is okay, then that might help.