import { defineConfig } from "vite"

// Cross-origin isolation (COOP + COEP) is required for SharedArrayBuffer, which
// the multi-threaded renderer uses to share the framebuffer across workers.
// Without these headers the app still runs -- it falls back to single-threaded.
const crossOriginIsolation = {
  "Cross-Origin-Opener-Policy": "same-origin",
  "Cross-Origin-Embedder-Policy": "require-corp",
}

export default defineConfig({
  resolve: {
    tsconfigPaths: true,
  },
  worker: {
    format: "es",
  },
  server: {
    headers: crossOriginIsolation,
  },
  preview: {
    headers: crossOriginIsolation,
  },
})
