fix(pwa): Enable NetworkOnly Service Worker to allow installation without lag
This commit is contained in:
parent
c6769cb884
commit
b7c121a084
1 changed files with 6 additions and 2 deletions
|
|
@ -14,8 +14,7 @@ export default defineConfig(({ mode }) => {
|
||||||
react(),
|
react(),
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
injectRegister: null, // Disable automatic SW injection to fix lag
|
injectRegister: 'auto', // Re-enable SW for installation criteria
|
||||||
selfDestroying: true, // Force unregister existing SW
|
|
||||||
includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'masked-icon.svg'],
|
includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'masked-icon.svg'],
|
||||||
manifest: {
|
manifest: {
|
||||||
name: 'FoodSnap.ai',
|
name: 'FoodSnap.ai',
|
||||||
|
|
@ -45,6 +44,11 @@ export default defineConfig(({ mode }) => {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
workbox: {
|
workbox: {
|
||||||
|
// NetworkOnly strategy to prevent caching issues/lag but allow installation
|
||||||
|
runtimeCaching: [{
|
||||||
|
urlPattern: ({ request }) => request.destination === 'document' || request.destination === 'script' || request.destination === 'style' || request.destination === 'image',
|
||||||
|
handler: 'NetworkOnly',
|
||||||
|
}],
|
||||||
cleanupOutdatedCaches: true,
|
cleanupOutdatedCaches: true,
|
||||||
skipWaiting: true,
|
skipWaiting: true,
|
||||||
clientsClaim: true,
|
clientsClaim: true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue