import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; const CONFIG_DIR = path.dirname(fileURLToPath(import.meta.url)); const POM_PATH = path.resolve(CONFIG_DIR, "../backend/pom.xml"); function resolveAppVersion() { const content = fs.readFileSync(POM_PATH, "utf8"); const parentRange = content.indexOf(""); const parentEnd = content.indexOf(""); const withoutParent = content.slice(0, parentRange) + content.slice(parentEnd + "".length); const match = withoutParent.match(/(\d+\.\d+\.\d+)<\/version>/); if (match) { return match[1]; } throw new Error(`Version konnte nicht aus ${POM_PATH} ermittelt werden.`); } export default defineConfig({ plugins: [react()], define: { __APP_VERSION__: JSON.stringify(resolveAppVersion()), }, server: { port: 5173, host: "0.0.0.0", }, });