Repository navigation
fix(pwa): let docs navigations past the service worker - #68
Merged
Merged
Conversation
The mdBook docs are deployed under /werb/docs/, inside the PWA service worker's /werb/ scope. Workbox answers every unknown navigation with the precached index.html, and the docs are copied into dist/ after the Vite build so they are never precached: once a browser had opened the app, every docs URL (README, issues, CLI help links) showed the app instead. navigateFallbackDenylist now excludes <base>docs/ so those navigations go to the network. Browsers with the old worker get the fix after accepting the next update. Tests: e2e drives the production bundle, waits for the worker to control the page, then loads a page under docs/ (fails without the fix: the app shell comes back).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Once a browser has opened the web app, every link to https://werb-dev.github.io/werb/docs/ shows the app instead of the documentation.
The service worker's scope is
/werb/, and the docs live in/werb/docs/. Workbox answers any navigation it doesn't know with the precachedindex.html. The docs are copied intodist/after the Vite build, so they're never precached and always hit that fallback.Reproduced on the live site in Chromium:
/werb/docs//werb/docs/install.html/werb/docs/werb/docs/, docsFix
navigateFallbackDenylist: [^<base>docs(/|$)]in the Workbox config, so navigations underdocs/go to the network. The regex followsVITE_BASE: it is/^\/werb\/docs(\/|$)/on Pages and/^\/docs(\/|$)/locally.Browsers that already have the old worker pick up the fix after accepting the next update (the "New version available" banner).
Tests
test/e2e/pwa.spec.ts: drops a probe page intodist/docs/, waits for the worker to control the page, then navigates to the probe.