From 0e696e05ccbaf29780405711a0aa188d2adbefa0 Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Thu, 12 Jun 2025 12:57:25 -0400 Subject: [PATCH] Add builds --- web/index.html | 1 + web/src/router/AppRouter.jsx | 10 ++++++++++ web/vite.config.js | 12 +++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/web/index.html b/web/index.html index 933180d..5ca2263 100644 --- a/web/index.html +++ b/web/index.html @@ -7,6 +7,7 @@ + ShiftSync diff --git a/web/src/router/AppRouter.jsx b/web/src/router/AppRouter.jsx index 19d6710..5fa17a6 100644 --- a/web/src/router/AppRouter.jsx +++ b/web/src/router/AppRouter.jsx @@ -69,6 +69,16 @@ const AppRouter = () => { }; useEffect(() => { + const localVersion = localStorage.getItem("APP_VERSION"); + const currentVersion = window.APP_VERSION; + + if (localVersion && localVersion !== currentVersion) { + console.log("Version changed, forcing reload"); + localStorage.setItem("APP_VERSION", currentVersion); + window.location.reload(true); // force full page reload + } else { + localStorage.setItem("APP_VERSION", currentVersion); + } fetchAPI(); // await call for getting the count of employees and any other calls to db. diff --git a/web/vite.config.js b/web/vite.config.js index 68c4221..1dba73d 100644 --- a/web/vite.config.js +++ b/web/vite.config.js @@ -1,10 +1,20 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import path from 'path'; +import pkg from './package.json'; // https://vite.dev/config/ export default defineConfig({ - plugins: [react()], + plugins: [ + react(), + { + name: 'html-transform', + transformIndexHtml(html) { + return html + .replace(/__appVersion__/g, pkg.version) + } + } + ], server:{ host: true, allowedHosts: true,