Emberjs-confgr-ember-app-cli

提供:Dev Guides
移動先:案内検索

EmberJS-アプリとEmber CLIの構成

EmberアプリとCLIを構成して、アプリケーションの環境を管理できます。 環境設定ファイルは_config/environment.js_にあります。 次のコード構造が含まれています-

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;
};

_ENV_オブジェクトには、次の3つのキーが含まれています-

  • EmberENV -Ember機能フラグを提供します。
  • APP -フラグ/オプションをアプリケーションインスタンスに渡すために使用されます。
  • environment -development、production _、 test_などの現在の環境名を提供します。

Ember CLIの構成

Ember CLIを構成するには、アプリケーションのルートにある_.ember-cli_ファイルに構成を追加します。

たとえば、コマンドラインからコマンドember server --port 8080_を使用してポート番号を渡すことができます。 この構成は、以下に示すように.ember-cli_ファイルに追加できます-

{
   "port" : 8080
}