Precache hashed bundles and revision the PWA service worker
- Add a build-only Vite plugin (admin/vite-sw-plugin.ts) that, after the bundle is written, injects every same-origin script/link asset referenced by dist/index.html into dist/sw.js's precache, so the offline shell renders immediately after install (PWA-001). - Replace the literal cache version with a build revision (sha256 of the built index.html and sw.js source, truncated) used in both cache names, so each release installs a new worker with fresh caches (PWA-002). - On activate, delete only stale nestquest-admin-* caches; unrelated same-origin caches survive (PWA-003). - Add Vitest regressions for all three findings. Task: 96ab3c0b-7554-4098-8af1-2be7815f8929 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { serviceWorkerInjectPlugin } from "./vite-sw-plugin";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
plugins: [react(), serviceWorkerInjectPlugin()],
|
||||
test: {
|
||||
environment: "jsdom",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user