GoogleChromeLabs / sw-precache

[Deprecated] A node module to generate service worker code that will precache specific resources so they work offline.
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
Apache License 2.0
5.22k stars 388 forks source link

Conditional Navigate Fallback #322

Closed Ixonal closed 7 years ago

Ixonal commented 7 years ago

Is there a way to make the navigate fallback be different based on some runtime condition? Basically, I have two pages that are both SPAs with push state routing at "/" and "/admin". As-is, I have the navigate fallback just going back to the SPA at "/", but I'd like to be able to have the fallback be "/admin" if "/admin/" is anywhere in the url, or "/" otherwise.

jeffposnick commented 7 years ago

No, unfortunately there's not. This is possible if you migrate to Workbox, which has support for multiple navigation routes, each with their own white/blacklists.

Ixonal commented 7 years ago

hmmm... Was putting that off for a while due to how new it is and rather unhelpful Webpack documentation.

jeffposnick commented 7 years ago

I can understand wanting to wait a bit following a new release, but this is one case where your use case is only met with the newer library.

We would like to make the Webpack documentation more helpful!

CC: @prateekbh @kaycebasques if you have any specific complaints/comments about it. (Or feel free to open an issue at https://github.com/GoogleChrome/workbox/issues)

prateekbh commented 7 years ago

I guess I can open a PR to make the current example more verbose.

Ixonal commented 7 years ago

sorry it took a bit to reply, kinda zoned out after work.

The main things I'd suggest for the documentation would be to explain what the Webpack plugin does (I'm guessing it inserts code into a predefined service worker if passed in, or creates a new one if not), and have more verbose explanations of what the options do in the reference docs (right now, that page looks about the same as the get started page). If writing the service worker is necessary beyond configuring the plugin, that'd be good to note as well.