From 66bac50de37e77f9ee2dd8d8eda1877318c665ad Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Fri, 28 Jul 2023 20:17:24 +0530 Subject: [PATCH] fix: refresh sw when browser refreshed (#6824) * fix: refresh sw when browser refreshed * dummy test * enable immediate reload * test * fix * autoupdate * don't immediate * test * testing testing * test * test * its same * revert logs * fix types --------- --- src/index.tsx | 3 +++ src/vite-env.d.ts | 3 +-- vite.config.ts | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index d0f333ec..ea8c39cb 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,11 +1,14 @@ import { StrictMode } from "react"; import { createRoot } from "react-dom/client"; import ExcalidrawApp from "./excalidraw-app"; +import { registerSW } from "virtual:pwa-register"; import "./excalidraw-app/sentry"; window.__EXCALIDRAW_SHA__ = import.meta.env.VITE_APP_GIT_SHA; const rootElement = document.getElementById("root")!; const root = createRoot(rootElement); +registerSW(); + root.render( diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 8843ecc3..624f4cf4 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -1,8 +1,7 @@ /// -/// +/// /// /// - interface ImportMetaEnv { // The port to run the dev server VITE_APP_PORT: string; diff --git a/vite.config.ts b/vite.config.ts index fe3c2c23..4a4d72e3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -53,6 +53,7 @@ export default defineConfig({ svgrPlugin(), ViteEjsPlugin(), VitePWA({ + registerType: "autoUpdate", devOptions: { /* set this flag to true to enable in Development mode */ enabled: false,