
babel-plugin-transform-environment-variables-to-getters
The babel plugin to transform inline environment variables to value getters
Install
$ npm i babel-plugin-transform-environment-variables-to-getters
Example
In
console.log(process.env.NODE_ENV)
console.log(process.env.NODE_DEBUG)
Out
Via .babelrc with no options.exclude/include
{
"plugins": [
["transform-environment-variables-to-getters", {
"envFilepath": "/path/to/get-env.js"
}]
]
}
Out
const __getProcessEnvs = require('/path/to/get-env.js')
console.log(__getProcessEnvs().NODE_ENV)
console.log(__getProcessEnvs().NODE_DEBUG)
Via .babelrc with options
{
"plugins": [
["transform-environment-variables-to-getters", {
"envFilepath": "/path/to/get-env.js",
"exclude": ["NODE_DEBUG"]
}]
]
}
Out
const __getProcessEnvs = require('/path/to/get-env.js')
console.log(__getProcessEnvs().NODE_ENV)
console.log(process.env.NODE_DEBUG)
options Object
- envFilepath
path the path of the environment file which should be a literal string
- getterIdentifier?
string='__getProcessEnvs' the identifier name of the env getter method
- include?
Array<string> keys to include. If not specified, all keys which are not excluded will be included
- exclude?
Array<string> keys to exclude.
License
MIT