From ded3423a19e9a0ca2aa9c239f593cccfcc094a87 Mon Sep 17 00:00:00 2001 From: Jan-Henrik Bruhn Date: Sat, 13 Dec 2025 23:48:05 +0100 Subject: [PATCH] feature: Add application version to page title MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Read version from package.json at build time using Vite define - Create global __APP_VERSION__ constant injected by Vite - Update document title in App component to include version (e.g., "Respira v0.0.0") - Works reliably in both web and Electron builds 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- src/App.tsx | 4 ++++ src/vite-env.d.ts | 3 +++ vite.config.mts | 8 ++++++++ 3 files changed, 15 insertions(+) create mode 100644 src/vite-env.d.ts diff --git a/src/App.tsx b/src/App.tsx index 6d0bdb6..c2e8c7f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,6 +15,10 @@ import { CheckCircleIcon, BoltIcon, PauseCircleIcon, ExclamationTriangleIcon, Ar import './App.css'; function App() { + // Set page title with version + useEffect(() => { + document.title = `Respira v${__APP_VERSION__}`; + }, []); // Machine store const { isConnected, diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts new file mode 100644 index 0000000..dbb4c62 --- /dev/null +++ b/src/vite-env.d.ts @@ -0,0 +1,3 @@ +/// + +declare const __APP_VERSION__: string; diff --git a/vite.config.mts b/vite.config.mts index 4eae5c6..334ee21 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -4,8 +4,13 @@ import { viteStaticCopy } from 'vite-plugin-static-copy' import tailwindcss from '@tailwindcss/vite' import { dirname, join } from 'path' import { fileURLToPath } from 'url' +import { readFileSync } from 'fs' import type { Plugin } from 'vite' +// Read version from package.json +const packageJson = JSON.parse(readFileSync('./package.json', 'utf-8')) +const appVersion = packageJson.version + const PYODIDE_EXCLUDE = [ '!**/*.{md,html}', '!**/*.d.ts', @@ -133,6 +138,9 @@ export function downloadPyPIWheels(packages: PyPIPackage[]): Plugin { // https://vite.dev/config/ export default defineConfig({ + define: { + __APP_VERSION__: JSON.stringify(appVersion), + }, plugins: [ react(), tailwindcss(),