There are several parts of the code that we use for development, such as the dotenv package. We would like to wrap these part in a conditional statement that checks against the current environment. For example, in server.js,
if (app.get("ENV") !== "PRODUCTION") {
require("dotenv").config();
}
As seen above, we'd only want to use the dotenv package to read environment variable from a git-ignored file .env when we're on development mode. If we are on production, we shouldn't have to do this; instead, we should config the variables directly on Heroku's dashboard and let the deployed app use it.
There may be other parts of the code that behave like the example above, and so we need to branch them according to the environment.
There are several parts of the code that we use for development, such as the
dotenv
package. We would like to wrap these part in a conditional statement that checks against the current environment. For example, inserver.js
,As seen above, we'd only want to use the
dotenv
package to read environment variable from a git-ignored file.env
when we're on development mode. If we are on production, we shouldn't have to do this; instead, we should config the variables directly on Heroku's dashboard and let the deployed app use it.There may be other parts of the code that behave like the example above, and so we need to branch them according to the environment.