import { fileURLToPath, URL } from "node:url"; import { defineConfig } from "vite"; import react, { reactCompilerPreset } from "@vitejs/plugin-react"; import babel from "@rolldown/plugin-babel"; import tailwindcss from "@tailwindcss/vite"; // wasm-vips and the jSquash codecs ship their own .wasm (and spawn their own // workers), so they must not be pre-bundled; the whole graph needs an esnext target. const wasmDeps = ["wasm-vips", "@jsquash/jpeg", "@jsquash/png", "@jsquash/webp", "@jsquash/avif"]; export default defineConfig({ plugins: [ react(), // React Compiler runs as a Babel preset (Vite 8 / Rolldown uses Oxc for the // main transform, so the compiler is layered in via @rolldown/plugin-babel). babel({ presets: [reactCompilerPreset()] }), tailwindcss(), ], resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)), }, }, worker: { format: "es", }, optimizeDeps: { exclude: wasmDeps, }, build: { target: "esnext", }, server: { // Cross-origin isolation lets the threaded wasm builds use SharedArrayBuffer. headers: { "Cross-Origin-Opener-Policy": "same-origin", "Cross-Origin-Embedder-Policy": "require-corp", }, }, preview: { headers: { "Cross-Origin-Opener-Policy": "same-origin", "Cross-Origin-Embedder-Policy": "require-corp", }, }, });