mirror of
https://github.com/Xevion/banner.git
synced 2026-01-31 04:23:34 -06:00
feat: better frontend state implementation, acquire version in frontend build time
This commit is contained in:
@@ -2,6 +2,22 @@ import { defineConfig } from "vite";
|
||||
import viteReact from "@vitejs/plugin-react";
|
||||
import tanstackRouter from "@tanstack/router-plugin/vite";
|
||||
import { resolve } from "node:path";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
// Extract version from Cargo.toml
|
||||
function getVersion() {
|
||||
try {
|
||||
const cargoTomlPath = resolve(__dirname, "..", "Cargo.toml");
|
||||
const cargoTomlContent = readFileSync(cargoTomlPath, "utf8");
|
||||
const versionMatch = cargoTomlContent.match(/^version\s*=\s*"([^"]+)"/m);
|
||||
return versionMatch ? versionMatch[1] : "unknown";
|
||||
} catch (error) {
|
||||
console.warn("Could not read version from Cargo.toml:", error);
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const version = getVersion();
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
@@ -29,4 +45,7 @@ export default defineConfig({
|
||||
outDir: "dist",
|
||||
sourcemap: true,
|
||||
},
|
||||
define: {
|
||||
__APP_VERSION__: JSON.stringify(version),
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user