Environment configuration allows us to include or not include certain things in the build given certain configuration options. For example, we probably want to not include live reload for production builds, for this we need to have different environments. When building, we can provide an environment flag option. So lets go ahead and configure things to support this.
yarn add --dev broccoli-env@^0.0.1
broccoli-stew package also comes with an
env utility, with a slightly different API, but it doesn't expose
the environment name, and I want to be able to print it to the console, so I'm using the
broccoli-env package instead.
What we've done here is wrapped the
LiveReload section in an
env === "development", this ensures the
LiveReload trees are not included in the build when making a production build.
In order to pass in a different environment, simply add
BROCCOLI_ENV=production before the build command, e.g.
BROCCOLI_ENV=production broccoli build dist. To make this simpler, lets add a new run command in
yarn build-prod will build in "production" mode.
Completed Branch: 11-environment