Skip to content
File

Blob: vite.config.ts

typescript47 lines
1import { fileURLToPath, URL } from "node:url";
2import { defineConfig } from "vite";
3import react, { reactCompilerPreset } from "@vitejs/plugin-react";
4import babel from "@rolldown/plugin-babel";
5import tailwindcss from "@tailwindcss/vite";
6 
7// wasm-vips and the jSquash codecs ship their own .wasm (and spawn their own
8// workers), so they must not be pre-bundled; the whole graph needs an esnext target.
9const wasmDeps = ["wasm-vips", "@jsquash/jpeg", "@jsquash/png", "@jsquash/webp", "@jsquash/avif"];
10 
11export default defineConfig({
12 plugins: [
13 react(),
14 // React Compiler runs as a Babel preset (Vite 8 / Rolldown uses Oxc for the
15 // main transform, so the compiler is layered in via @rolldown/plugin-babel).
16 babel({ presets: [reactCompilerPreset()] }),
17 tailwindcss(),
18 ],
19 resolve: {
20 alias: {
21 "@": fileURLToPath(new URL("./src", import.meta.url)),
22 },
23 },
24 worker: {
25 format: "es",
26 },
27 optimizeDeps: {
28 exclude: wasmDeps,
29 },
30 build: {
31 target: "esnext",
32 },
33 server: {
34 // Cross-origin isolation lets the threaded wasm builds use SharedArrayBuffer.
35 headers: {
36 "Cross-Origin-Opener-Policy": "same-origin",
37 "Cross-Origin-Embedder-Policy": "require-corp",
38 },
39 },
40 preview: {
41 headers: {
42 "Cross-Origin-Opener-Policy": "same-origin",
43 "Cross-Origin-Embedder-Policy": "require-corp",
44 },
45 },
46});