Creates the ConfigPlugin.
Builds an immutable configuration snapshot from the environment.
Options for ConfigPlugin and loadConfig.
-
envFileOptional: boolean
When
true, a path inConfigPluginOptions.envFilePaththat does not exist is skipped instead of throwing. Defaults tofalse, which is the behaviour released in 0.1.0. -
envFilePath: string | readonly string[]
Path or paths to
.envfiles to load. Defaults to no file loading. When supplied, the runtime must providefs(absent on edge platforms). -
expandVariables: boolean
When
true(default), expand${NAME}references in values. Set tofalseto disable variable expansion. -
instance: IConfig
An already-loaded configuration snapshot to use verbatim.
-
validationSchema: StructuralSchema<unknown>
A structural schema (e.g., a Zod schema) for validating configuration at startup. When provided, the schema's
parse()is called once after merging and expansion, and the parsed output is stored as the configuration snapshot. This preserves Zod coercions and defaults.
Minimal structural schema interface compatible with Zod's parse(unknown)
API. Consumers supply a Zod schema without config-plugin depending on Zod.
-
parse(input: unknown): T
Parses and validates the input, applying coercions and defaults.
Usage
import * as Configuration_management_plugin_with_env_loading_and_Zod_validation___Provides__ConfigPlugin__which_registers_a_type_safe___linkcode_IConfig__under__CAPABILITIES_CONFIG___Configuration_values_originate_from_environment_variables_and___env__files__validated_at_startup___Every_export_here_is_public_API_and_documented_in_PUBLIC_API_md__AI_GUIDELINES__10__ from "config-plugin/src/index.ts";