Description
Feature request
Is your feature request related to a problem? Please describe.
Currently, built-in environments allows only .env.development
and .env.production
environments, so when you run yarn dev
it uses .env.development
or .env.local
and when you do yarn build
, then yarn start
it uses .env.production
environment. But there's no way to use a staging environment for example, like .env.staging
, there's no way to run app with staging environment, if we try to NODE_ENV=staging yarn build && yarn start
we get an error: "https://github.com/zeit/next.js/blob/master/errors/non-standard-node-env.md", and it won't have effect, because NODE_ENV
would be production anyway, it's being overwritten.
Describe the solution you'd like
There should be a way to set environment when you run your app, like NODE_ENV=staging/prestaging yarn build && yarn start
, etc. In CRA i use it this way:
"build:staging": "env-cmd -f .env.staging yarn build",
"build:prestaging": "env-cmd -f .env.prestaging yarn build"
Would be nice to have the same, but built-in in Next.
PS
"build:staging": "env-cmd -f .env.staging yarn build && yarn start"
this actually works with Next either, though NODE_ENV
would be set to "production".