import fs from "node:fs/promises"; import path from "node:path"; import type { Assets } from "./assets.js"; import type { Bindings } from "./bindings.js"; import { Website, type WebsiteProps } from "./website.js"; import type { Worker } from "./worker.js"; export interface ViteProps extends WebsiteProps {} // don't allow the ASSETS to be overriden export type Vite = B extends { ASSETS: any } ? never : Worker; export async function Vite( id: string, props: ViteProps ): Promise> { return Website(id, { ...props, assets: props.assets ?? (await (async () => { try { await fs.access(path.join("dist", "client", "index.html")); return path.join(".", "dist", "client"); } catch { return path.join(".", "dist"); } })()), }); }