A Vite plugin that enables using environment variables and custom variables in HTML files by replacing placeholders like {{VAR}} with actual values at build time. Version 1.0.4 is the current stable release, updated irregularly. Key differentiators include support for custom prefixes/suffixes, the ability to exclude environment variables, and TypeScript definitions. It is minimal and focused on a single task, unlike heavier solutions like @vitejs/plugin-legacy or custom middleware.
npm install vite-plugin-html-variablesVerified import paths — ran on the pinned version, not inferred.
Shows basic usage of vite-plugin-html-variables with custom variables and env variable inclusion.
Use VITE_ prefix for env vars or add them to the `variables` object.
Restart the dev server after modifying .env or variables config.
Set excludeEnvVariables: false or use the variables object to include specific vars.
Upgrade to latest version and update config accordingly (default prefix='{{', suffix='}}').Install with: npm i -D vite-plugin-html-variables
Ensure VITE_ prefix is used in .env or add variable to `variables` config.
Use: import htmlVariables from 'vite-plugin-html-variables'
No dependency data recorded yet.