a016e45ef2
- Inject LOG_LEVEL at build time via Vite define (__LOG_LEVEL__, default: warn) - Create frontend logger utility (frontend/src/utils/logger.ts) mirroring backend API - Replace all console.error calls with log.error in MedicationsPage, AppContext, Auth - Supports levels: silent > error > warn > info > debug Closes #205
31 lines
971 B
TypeScript
31 lines
971 B
TypeScript
import { existsSync, readFileSync } from "fs";
|
|
import { defineConfig } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
// Read version from package.json at build time
|
|
const packageJson = JSON.parse(readFileSync("./package.json", "utf-8"));
|
|
|
|
// Default to localhost for local dev and CI.
|
|
// In Docker, prefer backend-dev to avoid localhost proxy failures.
|
|
const defaultBackendTarget = existsSync("/.dockerenv") ? "http://backend-dev:3000" : "http://localhost:3000";
|
|
const backendTarget = process.env.BACKEND_URL || defaultBackendTarget;
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
define: {
|
|
__APP_VERSION__: JSON.stringify(packageJson.version || "unknown"),
|
|
__LOG_LEVEL__: JSON.stringify(process.env.LOG_LEVEL || "warn"),
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
strictPort: true,
|
|
proxy: {
|
|
"/api": {
|
|
target: backendTarget,
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, ""),
|
|
},
|
|
},
|
|
},
|
|
});
|