shadowwalker / next-pwa

Zero config PWA plugin for Next.js, with workbox 🧰
MIT License
3.89k stars 325 forks source link

Generating sw.js and workbox-*.js in a subdirectory #286

Open ChrisAllday opened 3 years ago

ChrisAllday commented 3 years ago

Hi, I have a question regarding placing the generated files in a specific directory.

Is it possible to specify a directory inside the public folder such as /public/pwa, as a location for the service worker and workbox files?

shadowwalker commented 3 years ago

I think so, use dest config option.

ChrisAllday commented 3 years ago

@shadowwalker I did attempt that, however it still tries to load the sw.js from https://{url}/sw.js instead of checking https://{url}/pwa/sw.js.

Any idea how to change this as well?

shadowwalker commented 3 years ago

That's scope you should concern about. In most cases you want it to be loaded from the root path, only when you want the pwa in subpath like http://{url}/pwa/**/* and don't want the service worker to work for other paths like http://{url}/abc/**/*. So far I suggest you keep it in /public directly.

atuljain2995 commented 2 years ago

If we want it to be inside sub-folder then how can we achieve that without disturbing the scope.

atuljain2995 commented 2 years ago

Also is there any way I can have custom workbox file name ?

Rishab1207 commented 2 years ago

@shadowwalker Is it possible to load the service-worker from a CDN instead of the root URL? Like https://mycdnurl.com/sw.js rather than https://mywebsiteurl.com/sw.js? (stackoverflow url)