Inline environment variables
// assuming process.env.NODE_ENV is actually "development"
process.env.NODE_ENV;
"development";
npm install babel-plugin-transform-inline-environment-variables
.babelrc
// without options
{
"plugins": ["transform-inline-environment-variables"]
}
// with options
{
"plugins": [
["transform-inline-environment-variables", {
"include": [
"NODE_ENV"
]
}]
]
}
babel --plugins transform-inline-environment-variables script.js
require("babel-core").transform("code", {
plugins: ["transform-inline-environment-variables"]
});
include
- array of environment variables to includeexclude
- array of environment variables to exclude