Inline dotenv at build-time with babel-plugin-macros.
MIT License
Inline dotenv at build-time with babel-plugin-macros.
$ yarn add dotenv.macro
Note: You'll also need to install and configure babel-plugin-macros if you haven't already.
// .env
HOST=localhost
EXPAND_NODE_ENV="NODE_ENV=${NODE_ENV}"
// index.js
import { HOST } from 'dotenv.macro';
console.log(HOST);
↓ ↓ ↓ ↓ ↓ ↓
console.log(process && process.env && process.env.HOST || "localhost");
$ yarn install --pure-lockfile
$ yarn run format
$ yarn run eslint
$ yarn run test:watch
$ yarn run build