added versioning

This commit is contained in:
jpremill committed 2026-03-06 08:49:42 -05:00
1 parent 5b2da87f05
commit c82b112624
8 files changed
+3888 -107

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
/// <reference lib="webworker" />
declare const self: ServiceWorkerGlobalScope;
import { clientsClaim } from 'workbox-core';
import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching';
// Bump this version to force SW update - changes to this constant change the SW file hash
const CACHE_VERSION = '2026-03-06-v1';
// @ts-ignore - __WB_MANIFEST is injected at build time by vite-plugin-pwa
precacheAndRoute(self.__WB_MANIFEST);
cleanupOutdatedCaches();
// Force immediate activation of new SW
self.addEventListener('install', () => {
console.log('[SW] Installing, skipping waiting...');
self.skipWaiting();
});
self.addEventListener('activate', () => {
console.log('[SW] Activating, claiming clients...');
clientsClaim();
});
// Handle SKIP_WAITING message from client
self.addEventListener('message', (event) => {
if (event.data?.type === 'SKIP_WAITING') {
self.skipWaiting();
}
});