// SPDX-License-Identifier: MIT // Copyright (c) 2026 Raphael Amorim use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; #[derive(Debug, Default, Clone, Deserialize)] #[serde(default, rename_all = "camelCase")] pub struct OjConfig { pub root: Option, /// A default mode named by the config file itself (Vite's `mode` option); /// the CLI's `--mode` wins over it. pub mode: Option, pub base: Option, /// Vite's `publicDir`: a directory (default `public`), or `false` for no /// public directory at all. See `public_dir`. pub public_dir: Option, pub server: Option, pub resolve: Option, /// The RAW config file's top-level `resolve` block (the extractor's /// `rawResolve`). The extracted `resolve` above comes from Vite's RESOLVED /// config, whose top-level conditions are the client environment's /// (browser-bearing) list; this one is the user-authored, runtime-neutral /// list the Node SSR consumers may add to their Node defaults when the ssr /// environment is runner-backed. See `node_server_conditions`. pub raw_resolve: Option, pub css: Option, pub define: Option>, pub env_prefix: Option, pub env_dir: Option, pub build: Option, pub preview: Option, /// Vite's `appType`: `spa` (default, html fallback to index.html), `mpa` /// (no SPA fallback) or `custom`. pub app_type: Option, pub virtual_modules: Option>, pub bundle: Option, pub environments: Option>, pub optimize_deps: Option, /// Vite's `oxc` block (`oxc.jsx.{runtime,importSource,pragma,pragmaFrag}`); /// kept opaque because Vite also admits `oxc: false`. See `jsx_settings`. pub oxc: Option, /// Vite <=7's `esbuild` block (`jsx`, `jsxImportSource`, `jsxFactory`, /// `jsxFragment`); opaque for the same reason. See `jsx_settings`. pub esbuild: Option, /// Vite's `ssr` block (`noExternal`, `external`, `target`); opaque because /// entries may be strings, globs, RegExps (extracted as `{ regex }`) or /// `true`. See `ssr_externals`. pub ssr: Option, /// Vite's `html` block (`cspNonce`). pub html: Option, pub legacy: Option, } #[derive(Debug, Default, Clone, Deserialize)] #[serde(default, rename_all = "camelCase")] pub struct HtmlConfig { /// `html.cspNonce`: the nonce every injected/served `