/rollup-plugin-process-env

Rollup plugin to use process.env

Primary LanguageJavaScriptMIT LicenseMIT

NPM downloads changelog license

rollup-plugin-process-env

🍣 A Rollup plugin which injects process.env variables into build.

stars watchers

Install

npm i rollup-plugin-process-env

Usage

Use prefix to inject environments from current process.env which starts with the prefix.

import env from 'rollup-plugin-process-env'

export default {
  plugins: [
    env('MY_PREFIX_'),
  ],
}

Use dotenv and dotenv-expand to get environments from .env and outer environments

import env from 'rollup-plugin-process-env'

require('dotenv-expand').expand(require('dotenv').config())

export default {
  plugins: [
    env('MY_PREFIX_'),
  ],
}

Filter environments by name

import env from 'rollup-plugin-process-env'

const envs = ['MY_ENV', 'ANOTHER_MY_NAME']

export default {
  plugins: [
    env(name => envs.includes(name)),
  ],
}

Provide an object to include it as process.env

import env from 'rollup-plugin-process-env'

export default {
  plugins: [
    env({ MY_ENV: 'true' }),
  ],
}

Issues

If you find a bug or have a suggestion, please file an issue on GitHub.

issues