Package Exports
- babel-plugin-inline-dotenv
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-inline-dotenv) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
babel-plugin-inline-dotenv
Load your .env
file and replace process.env.MY_VARIABLE
with the value you set.
tl;dr
It actually 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.
Installation
$ npm install babel-plugin-inline-dotenv
Usage
Via .babelrc
(Recommended)
Without options:
.babelrc
{
"plugins": ["inline-dotenv"]
}
With options:
{
"plugins": [["inline-dotenv",{
path: 'path/to/.env' // See motdotla/dotenv for more options
}]]
}
To replace with env value without process && process.env && process.env.MY_VARIABLE ||
safety:
{
"plugins": [["inline-dotenv",{
unsafe: true
}]]
}
Via CLI
$ babel --plugins inline-dotenv script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["inline-dotenv"]
});