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(),
|
||||
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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue