1.0.0 • Published 6 years ago

babel-plugin-env-json v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

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"