A Rollup plugin that injects `process.env` variables into the build. Current stable version is 1.0.7 (released 2023). It supports prefix-based filtering, custom filter functions, or direct object mapping. Unlike @rollup/plugin-replace or @rollup/plugin-inject, this plugin specifically handles `process.env` references and offers built-in dotenv integration guidance. Ships TypeScript types. Release cadence is low; updates are infrequent. Key differentiators: simple API, no additional configuration for common use cases, and explicit support for dotenv/dotenv-expand.
npm install rollup-plugin-process-envVerified import paths — ran on the pinned version, not inferred.
Basic Rollup configuration that uses the plugin to inject two custom environment variables into the bundle.
Use only dot notation with static property names, or use a different plugin (e.g., @rollup/plugin-replace) for dynamic patterns.
Add `require('dotenv-expand').expand(require('dotenv').config())` at the top of your config file.Always use `process.env.X` directly in your code.
Use `import env from 'rollup-plugin-process-env'` in an ESM context (enable ESM in your package.json or use .mjs extension).
Rename rollup.config.js to rollup.config.mjs or set "type": "module" in package.json, then use import syntax.
Use `import env from 'rollup-plugin-process-env'` without curly braces.
Ensure your target environment supports `process`, or use a polyfill like @rollup/plugin-inject to define `process` globally.
No dependency data recorded yet.