fix(pwa): disable service worker in dev across all 8 vite configs
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:<name> # 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) <noreply@anthropic.com>
This commit is contained in:
parent
d37f37a36d
commit
613a925e45
8 changed files with 10 additions and 8 deletions
|
|
@ -51,7 +51,7 @@ export default defineConfig(({ mode }) => ({
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
devOptions: {
|
devOptions: {
|
||||||
enabled: true,
|
enabled: false,
|
||||||
},
|
},
|
||||||
workbox: {
|
workbox: {
|
||||||
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export default defineConfig(({ mode }) => ({
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
devOptions: {
|
devOptions: {
|
||||||
enabled: true,
|
enabled: false,
|
||||||
},
|
},
|
||||||
workbox: {
|
workbox: {
|
||||||
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export default defineConfig(({ mode }) => ({
|
||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
devOptions: { enabled: true },
|
devOptions: { enabled: false },
|
||||||
workbox: {
|
workbox: {
|
||||||
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
||||||
navigateFallback: 'chat.html',
|
navigateFallback: 'chat.html',
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ export default defineConfig(({ mode }) => ({
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
devOptions: {
|
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',
|
// strategies: 'injectManifest',
|
||||||
srcDir: 'public',
|
srcDir: 'public',
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export default defineConfig(({ mode }) => ({
|
||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
devOptions: { enabled: true },
|
devOptions: { enabled: false },
|
||||||
workbox: {
|
workbox: {
|
||||||
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
||||||
navigateFallback: 'forum.html',
|
navigateFallback: 'forum.html',
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export default defineConfig(({ mode }) => ({
|
||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
devOptions: { enabled: true },
|
devOptions: { enabled: false },
|
||||||
workbox: {
|
workbox: {
|
||||||
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
||||||
navigateFallback: 'market.html',
|
navigateFallback: 'market.html',
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export default defineConfig(({ mode }) => ({
|
||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
devOptions: { enabled: true },
|
devOptions: { enabled: false },
|
||||||
workbox: {
|
workbox: {
|
||||||
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
||||||
navigateFallback: 'tasks.html',
|
navigateFallback: 'tasks.html',
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ export default defineConfig(({ mode }) => ({
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
devOptions: {
|
devOptions: {
|
||||||
enabled: true,
|
enabled: false,
|
||||||
},
|
},
|
||||||
workbox: {
|
workbox: {
|
||||||
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue