- 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.
- 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
- 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/'
Create files inside env/{environment}.js based on the environment of your choice
env/*
!env/index.js
yarn dev
yarn start