From 613a925e457b3f72151c64e560bc3a0163437ef2 Mon Sep 17 00:00:00 2001 From: Padreug Date: Sat, 2 May 2026 10:58:34 +0200 Subject: [PATCH] fix(pwa): disable service worker in dev across all 8 vite configs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Was: every standalone (and the hub) registered a service worker during \`npm run dev\` via VitePWA's devOptions.enabled = true. Problem: the dev SW caches index.html and the JS bundle on first load and survives across vite restarts. Any code change that required a server restart (e.g. fixing a vite.config.ts merge conflict) resulted in browsers continuing to serve the cached pre-restart bundle until the user manually unregistered the SW. This caused the hub at localhost:5173 to redirect to /market on refresh — the cached bundle was from the broken-config period which still had the old monolithic main app's market route. PWA features (offline, install prompts, manifest) are still tested by running: npm run preview # for the hub npm run preview: # for any standalone against a real production build, which is the more accurate environment for PWA verification anyway. Recovery for anyone with a stale SW lingering in their browser (needed once after pulling, then never again): 1. DevTools → Application → Service Workers → Unregister 2. DevTools → Application → Storage → Clear site data 3. Hard reload (Ctrl-Shift-R) Co-Authored-By: Claude Opus 4.7 (1M context) --- vite.activities.config.ts | 2 +- vite.castle.config.ts | 2 +- vite.chat.config.ts | 2 +- vite.config.ts | 4 +++- vite.forum.config.ts | 2 +- vite.market.config.ts | 2 +- vite.tasks.config.ts | 2 +- vite.wallet.config.ts | 2 +- 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/vite.activities.config.ts b/vite.activities.config.ts index 5561a70..8131615 100644 --- a/vite.activities.config.ts +++ b/vite.activities.config.ts @@ -51,7 +51,7 @@ export default defineConfig(({ mode }) => ({ VitePWA({ registerType: 'autoUpdate', devOptions: { - enabled: true, + enabled: false, }, workbox: { globPatterns: ['**/*.{js,css,html,ico,png,svg}'], diff --git a/vite.castle.config.ts b/vite.castle.config.ts index bee4bb0..272009c 100644 --- a/vite.castle.config.ts +++ b/vite.castle.config.ts @@ -51,7 +51,7 @@ export default defineConfig(({ mode }) => ({ VitePWA({ registerType: 'autoUpdate', devOptions: { - enabled: true, + enabled: false, }, workbox: { globPatterns: ['**/*.{js,css,html,ico,png,svg}'], diff --git a/vite.chat.config.ts b/vite.chat.config.ts index c8bc86b..d49a067 100644 --- a/vite.chat.config.ts +++ b/vite.chat.config.ts @@ -45,7 +45,7 @@ export default defineConfig(({ mode }) => ({ tailwindcss(), VitePWA({ registerType: 'autoUpdate', - devOptions: { enabled: true }, + devOptions: { enabled: false }, workbox: { globPatterns: ['**/*.{js,css,html,ico,png,svg}'], navigateFallback: 'chat.html', diff --git a/vite.config.ts b/vite.config.ts index 025ded5..81d6e97 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,7 +15,9 @@ export default defineConfig(({ mode }) => ({ VitePWA({ registerType: 'autoUpdate', devOptions: { - enabled: true + // SW disabled in dev — was caching stale bundles across restarts. + // Run `npm run preview` to test PWA behaviour against a real build. + enabled: false }, // strategies: 'injectManifest', srcDir: 'public', diff --git a/vite.forum.config.ts b/vite.forum.config.ts index dcba841..fca9d11 100644 --- a/vite.forum.config.ts +++ b/vite.forum.config.ts @@ -45,7 +45,7 @@ export default defineConfig(({ mode }) => ({ tailwindcss(), VitePWA({ registerType: 'autoUpdate', - devOptions: { enabled: true }, + devOptions: { enabled: false }, workbox: { globPatterns: ['**/*.{js,css,html,ico,png,svg}'], navigateFallback: 'forum.html', diff --git a/vite.market.config.ts b/vite.market.config.ts index aa82257..c8e5f8d 100644 --- a/vite.market.config.ts +++ b/vite.market.config.ts @@ -45,7 +45,7 @@ export default defineConfig(({ mode }) => ({ tailwindcss(), VitePWA({ registerType: 'autoUpdate', - devOptions: { enabled: true }, + devOptions: { enabled: false }, workbox: { globPatterns: ['**/*.{js,css,html,ico,png,svg}'], navigateFallback: 'market.html', diff --git a/vite.tasks.config.ts b/vite.tasks.config.ts index b10c4b7..6fa6cd2 100644 --- a/vite.tasks.config.ts +++ b/vite.tasks.config.ts @@ -45,7 +45,7 @@ export default defineConfig(({ mode }) => ({ tailwindcss(), VitePWA({ registerType: 'autoUpdate', - devOptions: { enabled: true }, + devOptions: { enabled: false }, workbox: { globPatterns: ['**/*.{js,css,html,ico,png,svg}'], navigateFallback: 'tasks.html', diff --git a/vite.wallet.config.ts b/vite.wallet.config.ts index 0c108b2..153e4b9 100644 --- a/vite.wallet.config.ts +++ b/vite.wallet.config.ts @@ -50,7 +50,7 @@ export default defineConfig(({ mode }) => ({ VitePWA({ registerType: 'autoUpdate', devOptions: { - enabled: true, + enabled: false, }, workbox: { globPatterns: ['**/*.{js,css,html,ico,png,svg}'],