babel-plugin-env-json
Loads environment variables from a json file through import
statement.
Installation
$ npm install babel-plugin-env-json
Usage
.babelrc
{
"plugins": [["babel-plugin-env-json", {
"replacedModuleName": "babel-env-json"
}]]
}
env/default.json
{
"db":{
"host":"localhost",
"username":"root",
"password":"LOL"
},
"api":{
"endpoint":"https://google.com/api"
}
}
In your-code.js
import {db, api} from "babel-env-json"
connection.connect(db);
console.log(api.endpoint); // "https://google.com/api"