We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Originally posted by flybayer June 3, 2021
Blitz/Next use basically dotenv-flow to load env var files like .env, .env.test, .env.development.local, etc.
.env
.env.test
.env.development.local
That behavior relies on setting NODE_ENV to the appropriate value before invoking a CLI command.
Problems:
build
NODE_ENV=production
dev
NODE_ENV=development
NODE_ENV=test blitz build
NODE_ENV
Use APP_ENV to determine app environment instead of NODE_ENV. NODE_ENV will only be used for blitz dev vs blitz build.
APP_ENV
blitz dev
blitz build
The value of APP_ENV will determine which .env.[ENV].* files will be loaded.
.env.[ENV].*
APP_ENV=development
APP_ENV=production
blitz start
APP_ENV=test
APP_ENV=test blitz start
-e
blitz start -e test
With this solution, you can set APP_ENV to any string. Example: APP_ENV=staging which would load .env.staging
APP_ENV=staging
.env.staging
Any and all feedback is welcome!
The text was updated successfully, but these errors were encountered:
Nice, just spent the last hour trying to figure out why NODE_ENV was getting set to production when I thought it should be test!
Sorry, something went wrong.
beerose
Successfully merging a pull request may close this issue.
Discussed in blitz-js/blitz#2444
Originally posted by flybayer June 3, 2021
Problem
Blitz/Next use basically dotenv-flow to load env var files like
.env
,.env.test
,.env.development.local
, etc.That behavior relies on setting NODE_ENV to the appropriate value before invoking a CLI command.
Problems:
build
command must useNODE_ENV=production
anddev
must useNODE_ENV=development
.NODE_ENV=test blitz build
NODE_ENV
inside your app code to conditionally do things based on different environments.Proposed Solution
Use
APP_ENV
to determine app environment instead ofNODE_ENV
.NODE_ENV
will only be used forblitz dev
vsblitz build
.The value of
APP_ENV
will determine which.env.[ENV].*
files will be loaded.APP_ENV=development
forblitz dev
APP_ENV=production
forblitz build
andblitz start
APP_ENV=test
for Jest testsAPP_ENV=test blitz start
-e
flag likeblitz start -e test
With this solution, you can set
APP_ENV
to any string. Example:APP_ENV=staging
which would load.env.staging
Any and all feedback is welcome!
The text was updated successfully, but these errors were encountered: