diff --git a/activities.html b/activities.html index d227e52..b555a4d 100644 --- a/activities.html +++ b/activities.html @@ -3,6 +3,7 @@
+ diff --git a/castle.html b/castle.html index fe3f567..cee9c6f 100644 --- a/castle.html +++ b/castle.html @@ -3,6 +3,7 @@ + diff --git a/chat.html b/chat.html index 56634bb..fb83dee 100644 --- a/chat.html +++ b/chat.html @@ -3,6 +3,7 @@ + diff --git a/forum.html b/forum.html index 13e5e8a..8646936 100644 --- a/forum.html +++ b/forum.html @@ -3,6 +3,7 @@ + diff --git a/index.html b/index.html index c1f84b2..76e7922 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ + diff --git a/market.html b/market.html index 52feccb..3fc32d5 100644 --- a/market.html +++ b/market.html @@ -3,6 +3,7 @@ + diff --git a/src/accounting-app/main.ts b/src/accounting-app/main.ts index 22efcbc..ed477b2 100644 --- a/src/accounting-app/main.ts +++ b/src/accounting-app/main.ts @@ -1,7 +1,10 @@ import { startApp } from './app' import { registerSW } from 'virtual:pwa-register' +import { cleanupStaleDevServiceWorkers } from '@/lib/dev-sw-cleanup' import 'vue-sonner/style.css' +cleanupStaleDevServiceWorkers() + // PWA service worker with periodic updates const intervalMS = 60 * 60 * 1000 // 1 hour registerSW({ diff --git a/src/activities-app/main.ts b/src/activities-app/main.ts index c9c8429..e3bb49d 100644 --- a/src/activities-app/main.ts +++ b/src/activities-app/main.ts @@ -1,7 +1,10 @@ import { startApp } from './app' import { registerSW } from 'virtual:pwa-register' +import { cleanupStaleDevServiceWorkers } from '@/lib/dev-sw-cleanup' import 'vue-sonner/style.css' +cleanupStaleDevServiceWorkers() + // PWA service worker with periodic updates const intervalMS = 60 * 60 * 1000 // 1 hour registerSW({ diff --git a/src/chat-app/main.ts b/src/chat-app/main.ts index 472cdf2..7493491 100644 --- a/src/chat-app/main.ts +++ b/src/chat-app/main.ts @@ -1,7 +1,10 @@ import { startApp } from './app' import { registerSW } from 'virtual:pwa-register' +import { cleanupStaleDevServiceWorkers } from '@/lib/dev-sw-cleanup' import 'vue-sonner/style.css' +cleanupStaleDevServiceWorkers() + const intervalMS = 60 * 60 * 1000 registerSW({ onRegistered(r) { diff --git a/src/forum-app/main.ts b/src/forum-app/main.ts index 900623b..8b7df15 100644 --- a/src/forum-app/main.ts +++ b/src/forum-app/main.ts @@ -1,7 +1,10 @@ import { startApp } from './app' import { registerSW } from 'virtual:pwa-register' +import { cleanupStaleDevServiceWorkers } from '@/lib/dev-sw-cleanup' import 'vue-sonner/style.css' +cleanupStaleDevServiceWorkers() + const intervalMS = 60 * 60 * 1000 registerSW({ onRegistered(r) { diff --git a/src/lib/dev-sw-cleanup.ts b/src/lib/dev-sw-cleanup.ts new file mode 100644 index 0000000..fd3de93 --- /dev/null +++ b/src/lib/dev-sw-cleanup.ts @@ -0,0 +1,42 @@ +/** + * Unregister any service worker that was registered on this origin during + * a previous dev session (when VitePWA's devOptions.enabled was true). + * + * Once devOptions.enabled was turned off, Vite stopped registering SWs in + * dev — but the browser keeps the previously-registered SWs alive across + * server restarts. They then intercept navigation and serve cached, often + * stale, bundles. This call clears them out at app boot. + * + * Production builds skip this entirely so the legitimate SW from + * `registerSW()` survives. + */ +export async function cleanupStaleDevServiceWorkers(): Promise