cross-env is used to set environment variables inline when running node commands.
cross-env NODE_ENV=production webpack --config build/webpack.config.js
However when populating environment variables from .env files you'll need to use dotenv or similar.
It's common to have a separate .env file for each environment (.env.development, .env.production...). To configure this with dotenv you need to run dotenv.config
at the root of your project, to pick the right .env file.
dotenv.config({
path: path.resolve(__dirname, `${process.env.NODE_ENV}.env`)
});