29 lines
1017 B
JavaScript
29 lines
1017 B
JavaScript
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("<parent>");
|
|
const parentEnd = content.indexOf("</parent>");
|
|
const withoutParent = content.slice(0, parentRange) + content.slice(parentEnd + "</parent>".length);
|
|
const match = withoutParent.match(/<version>(\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",
|
|
},
|
|
});
|