import { readFileSync } from "node:fs"; import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; // Read once at config-eval time — cheaper than a plugin hook, and this file // only ever runs in Node (dev server / build), never bundled into the app. const pkg = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf-8")); export default defineConfig({ plugins: [react()], css: { preprocessorOptions: { // Opts into Dart Sass's modern API — avoids the "legacy-js-api" // deprecation warning on every build (Vite still defaults to the // legacy API for backward compatibility). scss: { api: "modern-compiler", }, }, }, // Exposes package.json's version as a compile-time constant — see // src/vite-env.d.ts for the matching ambient declaration, and // AppLayout.tsx for where it's rendered. define: { __APP_VERSION__: JSON.stringify(pkg.version), }, });