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".
This commit is contained in:
@@ -116,7 +116,7 @@ export function Sidebar() {
|
|||||||
style={{ borderTop: "1px solid var(--border)" }}
|
style={{ borderTop: "1px solid var(--border)" }}
|
||||||
>
|
>
|
||||||
<p className="text-xs font-mono hidden sm:block" style={{ color: "var(--text-4)" }}>
|
<p className="text-xs font-mono hidden sm:block" style={{ color: "var(--text-4)" }}>
|
||||||
API v3
|
v{__APP_VERSION__}
|
||||||
</p>
|
</p>
|
||||||
<div className="flex items-center gap-1.5 mx-auto sm:mx-0">
|
<div className="flex items-center gap-1.5 mx-auto sm:mx-0">
|
||||||
<button
|
<button
|
||||||
|
|||||||
1
packages/web/src/vite-env.d.ts
vendored
Normal file
1
packages/web/src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
declare const __APP_VERSION__: string;
|
||||||
@@ -1,16 +1,23 @@
|
|||||||
import { defineConfig } from "vite";
|
import { readFileSync } from "node:fs";
|
||||||
import react from "@vitejs/plugin-react";
|
|
||||||
import { tanstackRouter } from "@tanstack/router-plugin/vite";
|
|
||||||
import tailwindcss from "@tailwindcss/vite";
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
import { fileURLToPath } from "url";
|
import { tanstackRouter } from "@tanstack/router-plugin/vite";
|
||||||
|
import react from "@vitejs/plugin-react";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
import { defineConfig } from "vite";
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
const host = process.env.TAURI_DEV_HOST;
|
const host = process.env.TAURI_DEV_HOST;
|
||||||
|
const { version } = JSON.parse(
|
||||||
|
readFileSync(path.resolve(__dirname, "../../package.json"), "utf-8"),
|
||||||
|
) as { version: string };
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
clearScreen: false,
|
clearScreen: false,
|
||||||
plugins: [tanstackRouter({ autoCodeSplitting: true }), react(), tailwindcss()],
|
plugins: [tanstackRouter({ autoCodeSplitting: true }), react(), tailwindcss()],
|
||||||
|
define: {
|
||||||
|
__APP_VERSION__: JSON.stringify(version),
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"@": path.resolve(__dirname, "./src"),
|
"@": path.resolve(__dirname, "./src"),
|
||||||
|
|||||||
Reference in New Issue
Block a user