import { defineConfig } from "vite";
import type { Plugin } from "vite";
import react from "@vitejs/plugin-react";
import { viteSingleFile } from "vite-plugin-singlefile";
// ---------------------------------------------------------------------------
// EMBED build — inline EVERYTHING (JS + CSS) into ONE self-contained index.html
// so the grid can be hosted inside another app with no server and no side assets.
// Output: aios-web/web/dist-embed/index.html (consumed by platform/aios_grid.py).
// The standalone build (vite.config.ts -> dist/) is unchanged and keeps the /api
// fetch path; this config only changes packaging, never the app code.
// npm run build:embed
// ---------------------------------------------------------------------------
// Strip the /favicon.svg : it is an EXTERNAL asset ref that singlefile does
// not inline, and it would 404 inside the embed iframe — removing it keeps the
// built file genuinely self-contained (no external refs at all).
function stripFaviconLink(): Plugin {
return {
name: "aios-strip-favicon",
transformIndexHtml(html: string): string {
return html.replace(/\s*]*rel=["']icon["'][^>]*>/i, "");
},
};
}
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), stripFaviconLink(), viteSingleFile()],
base: "./",
build: {
outDir: "dist-embed",
// keep the standalone dist/ intact — never emptied by this build
emptyOutDir: true,
},
});