feat(experimental): add includeAllowlist
for generateSW
strategy
#108
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.
This PR allows deal with missing and SSR pages for
generateSW
strategy, can be used via Nuxtgenerate
orbuild
commands, it is similar to this one for VP vite-pwa/vitepress#23:generate
command, the module will use404
prerendered page when requesting a missing page: when online, the server will send 404 and client app will be forwarded to error page, when offline, the runtime caching will redirect to 404 (the page must be in the sw precache manifest) and the client app will be forwarded to error page but with 404 in the address barbuild
command, the sw will have the same behavior described requesting missing pages also for SSR pages.✔️ I need to update Vitest and add Playwright offline tests, added in pwa plugin repo.
There is a bug in Playwright and chromium about offline and service workers, it is not working, this expectation is failing:
https://github.com/vite-pwa/nuxt/pull/108/files#diff-4582f966059acac2f5f0f43eb765b42d4c0e39911f5aef7828cf4728a9ca2977R45
To test the new experimental allow list feature:
pnpm install && nr prepack
nr test:generate:allowlist && pnpm server playground/dist
/missing
: should forward to/missing
with404
pageoffline
in network tab and refresh missing page: should redirect to/404
with404
pageonline
, back to home and enter some text in the input, clickGO
button and refresh page, should workoffline
and refreshhi
page, should redirect to/404
with404
pagenr test:build:allowlist && && node playground/.output/server/index.mjs
/missing
: should forward to/missing
with404
pageoffline
in network tab and refresh missing page: should redirect to/
online
, back to home and enter some text in the input, clickGO
button and refresh page, should workoffline
and refreshhi
page, should redirect to/
In both cases,
hi
route should work whenoffline
and navigate viaGO
button.This feature is about avoid offline browser page, you can configure a custom page for the redirection when offline.
/cc @danielroe @antfu sorry guys, this PR is quite simple compared to #66, I'll check it with vitesse-nuxt and hi route, here we don't have any dynamic route (maybe we should add a simple
hi
SSR page 😅 )supersedes #66