Vite plugin that allows setting Vite config options via environment variables at build time. Current version 2.0.1, stable release cadence with occasional patches. Key differentiator: enables dynamic config overrides without modifying vite.config files, using a configurable prefix (default VITECONFIG_) and separator for nested object keys. Supports JSON-like value parsing with string fallback. Simple API, lightweight, TypeScript types included.
npm install vite-plugin-env-configVerified import paths — ran on the pinned version, not inferred.
Shows basic setup and usage with an example environment variable override
Upgrade to Node 14.13.1 or later, or stay on v1.x if you must use Node 12
Use JSON-compatible values: `true`, `false`, `"string"`, `123`. For string values that are not JSON, they remain strings.
Use a different approach for arrays (e.g., set as a JSON string and parse manually).
Use single underscore for path separator. If a property name contains underscore, double it (e.g., `VITECONFIG_foo__bar=1` sets `{foo: {bar: 1}}`).npm install vite-plugin-env-config --save-dev (or pnpm/yarn equivalent)
Check compatibility; currently v2.0.1 works with Vite 4.x. For Vite 5, look for an updated version or alternative plugin.
Use named import: `import { envConfig } from 'vite-plugin-env-config'`No dependency data recorded yet.