| 1 | import { access } from "node:fs/promises"; |
| 2 | import path from "node:path"; |
| 3 | import { preview } from "vite"; |
| 4 | |
| 5 | export async function startPreviewServer(root, port) { |
| 6 | const entry = path.join(root, "dist", "index.html"); |
| 7 | await access(entry).catch((cause) => { |
| 8 | throw new Error(`Browser gate requires the built frontend at ${entry}; build it or download the frontend artifact into dist.`, { cause }); |
| 9 | }); |
| 10 | return preview({ |
| 11 | root, |
| 12 | logLevel: "silent", |
| 13 | preview: { host: "127.0.0.1", port, strictPort: true }, |
| 14 | }); |
| 15 | } |
| 16 |