Open sgpinkus opened 8 months ago
PWA plugin options:
generateSW
strategy, use workbox
PWA plugin optioninjectManifest
strategy, use injectManifest
PWA plugin optionIf you use generateSW
strategy, then, you only need to configure
the runtime caching plugins (via workbox.runtimeCaching
), check VitePWA options
codesnippet here https://vite-pwa-org.netlify.app/workbox/generate-sw.html#cache-external-resources
vite-plugin-pwa
is a Workbox wrapper, you should be familiar with Workbox.
Types can be found here:
workbox
and injectManifest
pwa plugin options: https://github.com/vite-pwa/vite-plugin-pwa/blob/main/src/types.ts#L127-L134injectManifest
extending workbox-build InjectManifest
: https://github.com/vite-pwa/vite-plugin-pwa/blob/main/src/types.ts#L6workbox-build
types: https://github.com/vite-pwa/vite-plugin-pwa/blob/main/src/types.ts#L2@sgpinkus Feel free to send a PR if you want to modify/add some entries :pray:
Thanks for the pointers. Will be sure to PR to clarify doc once I understand how to cache-first and other policies configured and working correctly.
Docs state:
The linked workbox doc talks about cache-only, network-only, and cache-first-then-network, network-first-then-cache, showing you how to implement this if your implementing the caching yourself (and hence the entire service worker yourself). That's not really helpful - I'm using vite-pwa to avoid having to write the SW and caching implementation myself! Neither docs hint at a workbox or vite-pwa option to configure any one of the strategies.
AFAICT vite-pwa just generates a service worker with a cache-only strategy and there is no option to select a strategy. Is that the case? If so, saying "You can also configure how to control the network requests interception for any of your application resources" seems misleading/erroneous, and "configure" should be "implement you own".