import { sveltekit } from "@sveltejs/kit/vite"; import { defineConfig } from "vite"; import { execSync } from "node:child_process"; import path from "path"; // Build stamp rendered in the footer, so a deploy is visually identifiable. function buildId(): string { let commit = "unknown"; try { commit = execSync("git rev-parse --short HEAD", { stdio: ["ignore", "pipe", "ignore"], }) .toString() .trim(); } catch { // git is unavailable (for example when building from an exported tarball) } const stamp = new Date().toISOString().slice(0, 16).replace("T", " "); return `${commit} ${stamp}Z`; } export default defineConfig({ define: { __BUILD_ID__: JSON.stringify(buildId()), }, plugins: [sveltekit()], server: { port: 5173, // Allow all hosts (for ngrok and other tunnels) allowedHosts: true, }, resolve: { alias: { jgoboard: path.resolve(__dirname, 'node_modules/jgoboard/main.js'), }, }, });