@arkenv/vite-plugin
Exports and transform options for the Vite plugin.
API reference for @arkenv/vite-plugin. Setup recipes:
Vite guide.
Installation
npm install -D @arkenv/vite-plugin
npm install @arkenv/core arktypepnpm add -D @arkenv/vite-plugin
pnpm add @arkenv/core arktypeyarn add --dev @arkenv/vite-plugin
yarn add @arkenv/core arktypebun install --dev @arkenv/vite-plugin
bun install @arkenv/core arktypeOr if you use Zod, Valibot, or another Standard Schema validator:
npm install -D @arkenv/vite-plugin
npm install @arkenv/standardpnpm add -D @arkenv/vite-plugin
pnpm add @arkenv/standardyarn add --dev @arkenv/vite-plugin
yarn add @arkenv/standardbun install --dev @arkenv/vite-plugin
bun install @arkenv/standardExports
| Export | Role |
|---|---|
| default | arkenvPlugin plugin factory |
named arkenvPlugin | Plugin factory |
named arkenvVitePlugin | Host-explicit named alias |
./standard | Standard Schema plugin entry |
Transform options
Pass transform options only. A schema argument is rejected.
| Option | Default | Meaning |
|---|---|---|
schemaPath | auto (env.ts) | Schema module to transform |
clientPrefix | Vite envPrefix (VITE_) | Keys exposed to the client |
| Plus | (none) | All ArkEnvConfig fields except safe |
logger / logLevel | (none) | Logging |
Call arkenvPlugin() with no args, or an options object that includes
transform fields (schemaPath, clientPrefix, logging). Do not pass a
schema map or compiled type() to the plugin.
Startup validation
When the plugin is registered, it resolves env.ts and validates it during
Vite config resolution. Missing or invalid environment variables therefore
abort the dev server or production build before Vite is ready. The plugin
revalidates the schema when a relevant .env file or schema module changes
during HMR.
Without the plugin, validation is import-driven and runs when a module imports
env.ts. Startup fail-fast is the documented behavior of the existing plugin
contract; there is no default-off lazy-validation flag.