import path from 'path' ; import * as dotenv from 'dotenv' ; import dotenvExpand from 'dotenv-expand' ; param { string } dir export default function processEnv ( dir ) { const mode = process . env . NODE_ENV ; const dotenvFiles = [ mode && `.env.${ mode }.local` , mode !== 'test' && '.env.local' , mode && `.env.${ mode }` , '.env' , ] . filter ( Boolean ) as string [ ] ; dotenvFiles . forEach ( function ( env ) { dotenvExpand ( dotenv . config ( { path : path . resolve ( dir , env ) } ) ) ; } ) ; }