Files
eve-job-tracker/vite.config.ts

66 lines
1.4 KiB
TypeScript

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { execSync } from "child_process";
// Get git tag or commit hash for version
function getGitVersion(): string {
try {
// Try to get the exact tag for current commit
const tag = execSync("git describe --tags --exact-match", {
encoding: "utf-8",
stdio: ["pipe", "pipe", "ignore"],
}).trim();
if (tag) {
return tag;
}
} catch {
// No exact tag found, continue to fallbacks
}
try {
// Try to get the most recent tag
const tag = execSync("git describe --tags --abbrev=0", {
encoding: "utf-8",
stdio: ["pipe", "pipe", "ignore"],
}).trim();
if (tag) {
return tag;
}
} catch {
// No tags found, continue to commit hash
}
try {
// Fallback to commit hash if no tags exist
const commit = execSync("git rev-parse --short HEAD", {
encoding: "utf-8",
stdio: ["pipe", "pipe", "ignore"],
}).trim();
return commit;
} catch {
return "dev";
}
}
const __GIT_VERSION__ = getGitVersion();
// https://vitejs.dev/config/
export default defineConfig(() => ({
server: {
host: "::",
port: 8080,
},
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
define: {
__GIT_VERSION__: JSON.stringify(__GIT_VERSION__),
},
}));