shoc-frontend-new/vite.config.ts
2026-09-03 17:12:49 -03:00

51 lines
1.4 KiB
TypeScript

import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import { execFileSync } from "node:child_process";
import path from "node:path";
import { defineConfig, loadEnv } from "vite";
import { assertAbsoluteApiUrlHasApiSegment } from "./config/api-url-contract";
import { resolveSentryRelease } from "./config/sentry-release";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
assertAbsoluteApiUrlHasApiSegment(env.VITE_API_URL);
let gitCommit: string | undefined;
try {
gitCommit = execFileSync("git", ["rev-parse", "HEAD"], { encoding: "utf8" }).trim();
} catch {
gitCommit = undefined;
}
const sentryRelease = resolveSentryRelease(
env.VITE_APP_COMMIT_SHA || process.env.GITHUB_SHA || gitCommit,
process.env.CI === "true",
);
return {
plugins: [react(), tailwindcss()],
define: {
__APP_COMMIT_SHA__: JSON.stringify(sentryRelease.commitSha),
__SENTRY_RELEASE__: JSON.stringify(sentryRelease.release),
},
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
server: {
port: 3000,
proxy: {
"/api": {
target: env.VITE_API_TARGET ?? "http://localhost:5141",
changeOrigin: true,
secure: false,
},
},
},
build: {
outDir: "dist",
sourcemap: "hidden",
},
};
});