Files
Red-Bull-Tracker/vite.config.ts
T
Cursor Agent aa1bf1b21f Harden scanner startup and defer polyfill loading
- Fix waitForVideoReady race by re-checking after listeners and timing out
- Serialize iOS native scans with an in-flight guard and chained timeouts
- Lazy-load @undecaf/barcode-detector-polyfill only when scanning starts

Co-authored-by: Ned Halksworth <hello@nedhalksworth.com>
2026-05-27 22:01:48 +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`;
}