🍣 A Rollup plugin which injects process.env
variables into build.
npm i rollup-plugin-process-env
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' }),
],
}
If you find a bug or have a suggestion, please file an issue on GitHub.