From 04f9fec842eab1df639d3404d51bc4e4e70dca38 Mon Sep 17 00:00:00 2001 From: ledouxm Date: Mon, 8 Jul 2024 16:33:57 +0200 Subject: [PATCH] fix: update pwa cache if needed --- packages/frontend/package.json | 1 + packages/frontend/src/main.tsx | 7 +------ packages/frontend/vite.config.ts | 1 + 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 7363043a..eaf0242a 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "vite", "build": "pnpm icons && vite build", + "build:only": "vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "pnpm env:gen && vite preview --host", "env:gen": "vite-node ./scripts/createEnvFile.ts", diff --git a/packages/frontend/src/main.tsx b/packages/frontend/src/main.tsx index 5857800b..3aba228c 100644 --- a/packages/frontend/src/main.tsx +++ b/packages/frontend/src/main.tsx @@ -9,13 +9,8 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { ErrorBoundary } from "react-error-boundary"; import { registerSW } from "virtual:pwa-register"; -const ref = {} as any; - if ("serviceWorker" in navigator) { - registerSW({ - onRegistered: (r) => (ref.current = r), - onNeedRefresh: () => ref.current?.update(), - }); + registerSW({}); } startReactDsfr({ defaultColorScheme: "system", Link: Link }); diff --git a/packages/frontend/vite.config.ts b/packages/frontend/vite.config.ts index a8cad405..2aa45a5d 100644 --- a/packages/frontend/vite.config.ts +++ b/packages/frontend/vite.config.ts @@ -11,6 +11,7 @@ export default defineConfig({ wasm(), VitePWA({ devOptions: { enabled: true }, + registerType: "autoUpdate", manifest: { id: "gouv.beta.compte-rendu-vif", orientation: "portrait",