babel-plugin-env-json

1.0.0 • Public • Published

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"

/babel-plugin-env-json/

    Package Sidebar

    Install

    npm i babel-plugin-env-json

    Weekly Downloads

    10

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    37.2 kB

    Total Files

    12

    Last publish

    Collaborators

    • digital.flowers