Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (48 sloc) 2.35 KB
layout title permalink category github

Ember CLI ships with support for managing your application's environment. Ember CLI will build an environment config file at config/environment. Here, you can define an ENV object for each environment (development, test and production). For now, this is limited to the three environments mentioned.

The ENV object contains two important keys: 1) EmberENV, and 2) APP. The first can be used to define Ember feature flags (see the Feature Flags guide). The second can be used to pass flags/options to your application instance.

You can access these environment variables in your application code by importing from ../config/environment or your-application-name/config/environment.

For example:

{% highlight javascript %} import ENV from 'your-application-name/config/environment';

if (ENV.environment === 'development') { // ... } {% endhighlight %}

You can also import the ENV object in ./ember-cli-build.js in case you need environment variables in the build script.

{% highlight javascript %} const EmberApp = require('ember-cli/lib/broccoli/ember-app'); const ENV = require('./config/environment')(EmberApp.env()); {% endhighlight %}

Ember CLI assigns ENV.EmberENV to window.EmberENV, which Ember reads on application initialization.

Additionally, Ember CLI contains a number of environment-dependent helpers for assets:

It is now also possible to override command line options by creating a file in your app's root directory called .ember-cli and placing desired overrides in it.

For example, a common desire is to change the port that ember-cli serves the app from. It's possible to pass the port number directly to ember server in the command line, e.g. ember server --port 8080. If you wish to make this change a permanent configuration change, make the .ember-cli file and add the options you wish to pass to the server in a hash.

{% highlight javascript %} { "port": 8080 } {% endhighlight %}