configFileSource
Function: configFileSource()
Section titled “Function: configFileSource()”configFileSource(
options):StructuredSource
Defined in: sources.ts:245
A StructuredSource that discovers, imports, and returns the default
export of a *.config.* file — the building block for module-based config
(app.config.ts, app.config.json, …).
Resolution walks up from cwd (unless searchParents is false); within
each directory the configured extensions are tried in order and the first
existing file wins. A missing config file is soft — load() returns {}
so earlier layers (e.g. an objectSource of defaults) apply, mirroring
dotenvFileSource’s ENOENT handling.
Node only. Uses dynamic imports of node:fs/node:path/node:url.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Example
Section titled “Example”configFileSource({ name: "app", // → app.config.* extensions: ["ts", "js", "mjs", "cjs", "json"], // Compile TS/ESM on the fly so config-kit needs no compiler of its own: load: async (file) => (await import("jiti")).createJiti(import.meta.url)(file),})