EmberJS - Configuring App and Ember CLI



You can configure the Ember App and CLI for managing the application's environment. The environment config file will be present at config/environment.js. It contains the following code structure −

module.exports = function(environment) {
   var ENV = {
      modulePrefix: 'query-params', //it is the name of application
      environment: environment,
      baseURL: '/',
      locationType: 'auto',
      EmberENV: {
         
         FEATURES: {
            // Here you can enable experimental features on an ember canary build
            // e.g. 'with-controller': true
         }
      },

      APP: {
         // Here you can pass flags/options to your application instance
         // when it is created
         API_HOST: 'http://localhost:3000'
      }
   };

   if (environment === 'development') {
      //code here
   }

   if (environment === 'test') {
      //code here
   }

   if (environment === 'production') {
   }

   return ENV;
};

The ENV object includes the following three keys −

  • EmberENV − It provides the Ember feature flags.

  • APP − It is used to pass flags/options to your application instance.

  • environment − It provides the current environment names such as development, production and test.

Configuring Ember CLI

You can configure the Ember CLI by adding the configurations to the .ember-cli file which is present in your application's root.

For instance, you can pass the port number by using the command ember server --port 8080 from the command line. This configuration can be added in the .ember-cli file as shown below −

{
   "port" : 8080
}
emberjs_configuring_emberjs.htm
Advertisements