Serviceworker precaching only on absolute path?

Is there a way to add a path to a serviceworker?

By default, the generated serviceworker from a F7-PWA project, sets the path to an absolute path (e.g /static/docs/images/img.jpg).

So, if you don’t run the PWA from the root of the domain, pre-caching doesn’t work, and you’ll get error messages like:

Precaching did not find a match for /static/docs/images...

So - is there a way to fix this in F7 (or add a path to the service-worker)? (and where is the absolute path applied?).

I did check the F7-sources, but they are not really commented, so following the code there is getting tedious :wink:

any insights?

thx andy

It is handling by workbox plugin, you can check its docs

Hi @nolimits4web,

I checked the workbox docs, but couldn’t find anything which allows me to replace the absolute path with a relative path. Do you know that by heart?

Then it is handled by webpack, check webpack config, there should be something like publicPath