A Vite plugin that enables runtime environment variables, allowing a single build to be deployed across multiple environments by generating separate builds with environment-specific variables injected. Version 1.0.0 requires Vite 7.x and ships TypeScript type definitions. Released in 2025. Unlike compile-time env substitution, this plugin duplicates the output into per-mode directories with injected runtime variables, making it suitable for CI/CD workflows where you want to 'build once, deploy anywhere'.
npm install vite-plugin-runtime-dotenvNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configures the plugin with three modes, enables TypeScript declaration generation, and shows how to access variables in application code.
Upgrade Vite to version 7 or higher, or use an alternative plugin for older Vite.
Provide at least one mode in the 'modes' array.
Prefix your environment variables with VITE_ or configure the 'envPrefix' option in Vite.
Ensure your deployment script references the correct path, e.g., dist/qa/runtimeEnv.js.
import { runtimeEnv } from 'vite-plugin-runtime-dotenv'Add a non-empty 'modes' array to the plugin options.
Run 'npm install vite-plugin-runtime-dotenv' and ensure Vite version is >=7.0.0