diff --git a/vite.config.ts b/vite.config.ts index 33ad326..135a481 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -14,8 +14,7 @@ export default defineConfig(({ mode }) => { react(), VitePWA({ registerType: 'autoUpdate', - injectRegister: null, // Disable automatic SW injection to fix lag - selfDestroying: true, // Force unregister existing SW + injectRegister: 'auto', // Re-enable SW for installation criteria includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'masked-icon.svg'], manifest: { name: 'FoodSnap.ai', @@ -45,6 +44,11 @@ export default defineConfig(({ mode }) => { ] }, 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, skipWaiting: true, clientsClaim: true,