Statically extracts configuration from vite.config.* files without executing JavaScript.
Parses vite config files using oxc_parser and extracts
top-level fields whose values are pure JSON literals. This allows reading config like run
without needing a Node.js runtime (NAPI).
ESM:
export default { run: { tasks: { build: { command: "echo build" } } } }
export default defineConfig({ run: { cacheScripts: true } })CJS:
module.exports = { run: { tasks: { build: { command: 'echo build' } } } };
module.exports = defineConfig({ run: { cacheScripts: true } });Searches for config files in the same order as Vite's
DEFAULT_CONFIG_FILES:
vite.config.jsvite.config.mjsvite.config.tsvite.config.cjsvite.config.mtsvite.config.cts
resolve_static_config returns Option<FxHashMap<Box<str>, FieldValue>>:
None— config is not statically analyzable (no config file, parse error, noexport default/module.exports, or the exported value is not an object literal). Caller should fall back to runtime evaluation (e.g. NAPI).Some(map)— config object was successfully located:FieldValue::Json(value)— field value extracted as pure JSONFieldValue::NonStatic— field exists but contains non-JSON expressions (function calls, variables, template literals with interpolation, etc.)- Key absent — field does not exist in the config object
- Only extracts values that are pure JSON literals (strings, numbers, booleans, null, arrays, and objects composed of these)
- Fields with dynamic values (function calls, variable references, spread operators,
computed properties, template literals with expressions) are reported as
NonStatic - Does not follow imports or evaluate expressions