pramendra / managing-environemt-variables

Manage environment variables based on separate environment using es6

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Manage environement variables based on separate environemnt using es6

What is problem

  • dotenv only supports one file at a time ie dont offer variable overriding
  • ie merging .env and .env.production is not possible out of the box.

Solution

  • Use .env to set customer variables in node env
  • Use es6 to merge and manage additional variables such as for production and development using javascript files

How to use it

  • set common environement variables in .env
  • set the environement variable in the script using package.json such
  "start": "NODE_ENV=production nodemon --exec babel-node src/index.js",
  • Use following import to get envinonement varialbes import env from './../env/'

How to create new environment variables

Create files inside env/{environment}.js based on the environment of your choice

Things to do

Files to .gitignore

env/*
!env/index.js

How to test

run yarn to install package

test

development

yarn dev

production

yarn start

About

Manage environment variables based on separate environment using es6


Languages

Language:JavaScript 100.0%