Forked from babel-plugin-inline-env
and inspired by node-dotenv-extended
to support a common .env.defaults
file which other .env.*
can inherit from. Load your .env
and replace process.env.MY_VARIABLE
with the value you set. Variable expansion (as in dotenv-expand) is supported. This means any variables in .env.defaults
can also be expanded in the .env.*
files.
It replaces process.env.MY_VARIABLE
with:
process && process.env && process.env.MY_VARIABLE || 'value assigned to variable in dotenv'
This way, if the value is available at runtime it will be used instead.
$ npm install babel-plugin-inline-dotenv-expanded
Without options:
.babelrc
{
"plugins": ["inline-dotenv-expanded"]
}
With options:
{
"plugins": [["inline-dotenv-expanded",{
path: 'path/to/.env'
}]]
}
pm
$ babel --plugins inline-env script.js
require("babel-core").transform("code", {
plugins: ["inline-dotenv-expanded"]
});