Registry / devops / vite-plugin-env-config

vite-plugin-env-config

JSON →
library2.0.1jsnpmunverified

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-config
INSTALL
IMPORT
SIG · VITE-PLUGIN-ENV-CO
V
vite-plugin-env-config
devopsjavascriptv2.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

envConfig
import { envConfig } from 'vite-plugin-env-config'
const { envConfig } = require('vite-plugin-env-config')
ESM-only package; requires Node >=14.13.1

Shows basic setup and usage with an example environment variable override

// vite.config.ts import { defineConfig } from 'vite'; import { envConfig } from 'vite-plugin-env-config'; export default defineConfig({ plugins: [ envConfig({ prefix: 'VITECONFIG_', separator: '_' }) ] }); // Then run: // VITECONFIG_build_minify=false vite build // This overrides build.minify to false
Debug
Known issues
breakingDropped support for Node 12 in v2.0.0
fix
Upgrade to Node 14.13.1 or later, or stay on v1.x if you must use Node 12
affects: >=2.0.0
gotchaValue parsing uses JSON.parse; non-JSON values become strings. Booleans and numbers must be valid JSON (e.g., true, false, 42). Undefined/unquoted strings cause parse errors.
fix
Use JSON-compatible values: `true`, `false`, `"string"`, `123`. For string values that are not JSON, they remain strings.
affects: *
gotchaCannot set array items; only object properties are supported. Environment variable keys with numeric indices will be treated as object keys.
fix
Use a different approach for arrays (e.g., set as a JSON string and parse manually).
affects: *
gotchaEnvironment variable charset is limited to uppercase A-Z, underscore, and numbers. The prefix and property path must use underscore as separator; double underscore `__` is reserved for literal underscore in keys.
fix
Use single underscore for path separator. If a property name contains underscore, double it (e.g., `VITECONFIG_foo__bar=1` sets `{foo: {bar: 1}}`).
affects: *
Errors
Common errors & fixes
Cannot find module 'vite-plugin-env-config'
Package not installed or not in dependencies
fix
npm install vite-plugin-env-config --save-dev (or pnpm/yarn equivalent)
Error: The plugin 'vite-plugin-env-config' is not compatible with Vite 5
Plugin version may be outdated or not updated for Vite 5
fix
Check compatibility; currently v2.0.1 works with Vite 4.x. For Vite 5, look for an updated version or alternative plugin.
TypeError: envConfig is not a function
Possibly using a wrong import (default vs named).
fix
Use named import: `import { envConfig } from 'vite-plugin-env-config'`
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
vite-plugin-env-config — npm install vite-plugin-env-config · libregistry