Skip to content

Commit 7848d69

Browse files
feat(web): show app version in sidebar footer via Vite define
Reads version from root package.json at build time and injects it as __APP_VERSION__ via Vite define, replacing the hardcoded "API v3".
1 parent 123828c commit 7848d69

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

packages/web/src/components/layout/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function Sidebar() {
116116
style={{ borderTop: "1px solid var(--border)" }}
117117
>
118118
<p className="text-xs font-mono hidden sm:block" style={{ color: "var(--text-4)" }}>
119-
API v3
119+
v{__APP_VERSION__}
120120
</p>
121121
<div className="flex items-center gap-1.5 mx-auto sm:mx-0">
122122
<button

packages/web/src/vite-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare const __APP_VERSION__: string;

packages/web/vite.config.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
import { defineConfig } from "vite";
2-
import react from "@vitejs/plugin-react";
3-
import { tanstackRouter } from "@tanstack/router-plugin/vite";
1+
import { readFileSync } from "node:fs";
42
import tailwindcss from "@tailwindcss/vite";
5-
import { fileURLToPath } from "url";
3+
import { tanstackRouter } from "@tanstack/router-plugin/vite";
4+
import react from "@vitejs/plugin-react";
65
import path from "path";
6+
import { fileURLToPath } from "url";
7+
import { defineConfig } from "vite";
78

89
const __dirname = path.dirname(fileURLToPath(import.meta.url));
910
const host = process.env.TAURI_DEV_HOST;
11+
const { version } = JSON.parse(
12+
readFileSync(path.resolve(__dirname, "../../package.json"), "utf-8"),
13+
) as { version: string };
1014

1115
export default defineConfig({
1216
clearScreen: false,
1317
plugins: [tanstackRouter({ autoCodeSplitting: true }), react(), tailwindcss()],
18+
define: {
19+
__APP_VERSION__: JSON.stringify(version),
20+
},
1421
resolve: {
1522
alias: {
1623
"@": path.resolve(__dirname, "./src"),

0 commit comments

Comments
 (0)