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
generateSWstrategy, can be used via Nuxtgenerateorbuildcommands, it is similar to this one for VP vite-pwa/vitepress#23:generatecommand, the module will use404prerendered 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 barbuildcommand, 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 prepacknr test:generate:allowlist && pnpm server playground/dist/missing: should forward to/missingwith404pageofflinein network tab and refresh missing page: should redirect to/404with404pageonline, back to home and enter some text in the input, clickGObutton and refresh page, should workofflineand refreshhipage, should redirect to/404with404pagenr test:build:allowlist && && node playground/.output/server/index.mjs/missing: should forward to/missingwith404pageofflinein network tab and refresh missing page: should redirect to/online, back to home and enter some text in the input, clickGObutton and refresh page, should workofflineand refreshhipage, should redirect to/In both cases,
hiroute should work whenofflineand navigate viaGObutton.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
hiSSR page 😅 )supersedes #66