Files
Red-Bull-Tracker/vite.config.ts
T
Ned Halksworth 7bc92a92d7 tidy build config and deps
strip ollama proxy from vite, add deployment html injection plugin,
bump zxing dep for barcode scanning, ignore deploy artifacts
2026-05-27 16:40:06 +00:00

38 lines
994 B
TypeScript

import { existsSync, readFileSync } from "node:fs";
import react from "@vitejs/plugin-react";
import type { Plugin } from "vite";
import { defineConfig } from "vite";
export default defineConfig(({ command }) => ({
plugins: [react(), deploymentHtml(command === "build")],
build: {
chunkSizeWarningLimit: 700,
rollupOptions: {
output: {
manualChunks: {
charts: ["recharts"],
motion: ["framer-motion"],
icons: ["lucide-react"],
},
},
},
},
}));
function deploymentHtml(enabled: boolean): Plugin {
return {
name: "deployment-html",
transformIndexHtml(html) {
if (!enabled) return html;
return html
.replace("</head>", `${readOptional(".deploy/head.html")}</head>`)
.replace("</body>", `${readOptional(".deploy/body-end.html")}</body>`);
},
};
}
function readOptional(path: string) {
if (!existsSync(path)) return "";
return `\n${readFileSync(path, "utf8").trim()}\n`;
}