aboutsummaryrefslogtreecommitdiffstats
path: root/thallium-frontend/vite.config.ts
blob: 63d64d06e60605082dfef689707d956cab531c16 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import * as child from "child_process";

let commitHash = "unknown";

try {
  commitHash = child.execSync("git rev-parse --short HEAD")
    .toString().replace(/\n$/, "");
} catch (e) {
  console.error("Failed to get commit hash");
}

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  define: {
    VITE_APP_VERSION: JSON.stringify(process.env.npm_package_version),
    VITE_COMMIT_HASH: JSON.stringify(commitHash),
    THALLIUM_BASE_URL: JSON.stringify(process.env.THALLIUM_BASE_URL ?? "/api"),
  }
});