Sam Pakvis
1 min readNov 9, 2018

--

Hi Moses,

That’s a great question actually, and something I totally forgot to add in my article. I will elaborate on this later in the weekend, but in short:

You can add a path parameter to the dotenv config like this: dotenv.config({ path: '/path/to/env/file/.env '})

So if you set the current environment (e.g. “production”) as an environment variable in your NPM scripts( "build": "webpack --env.ENVIRONMENT=production”), you can use that variable to reference the correct .env file in your dotenv.config({}).

--

--

Sam Pakvis
Sam Pakvis

Written by Sam Pakvis

I eat frozen bread like toast

Responses (1)