2015-09-08 20 views
6

grunt-ng-constantという奇妙な問題が発生しています.3つのターゲットのうち2つしか動作しません。一貫性のない一定のターゲットが一貫して動作しない

私の構成は、次のようになります。

grunt.initConfig({ 
    ngconstant: { 
    options: { 
     space: ' ', 
     wrap: '"use strict";\n\n {%= __ngModule %}', 
     name: 'config' 
    }, 
    // Environment targets 
    development: { 
     options: { 
     dest: '<%= yeoman.app %>/scripts/config.js', 
     }, 
     constants: { 
     ENV: { 
      name: 'development', 
      apiEndpoint: 'http://your-development.api.endpoint:3000' 
     } 
     } 
    }, 
    staging: { 
     options: { 
     dest: '<%= yeoman.app %>/scripts/config.js', 
     }, 
     constants: { 
     ENV: { 
      name: 'staging', 
      apiEndpoint: 'http://your-staging.api.endpoint:3000' 
     } 
     } 
    }, 
    production: { 
     options: { 
     dest: '<%= yeoman.dist %>/scripts/config.js', 
     }, 
     constants: { 
     ENV: { 
      name: 'production', 
      apiEndpoint: 'http://api.livesite.com' 
     } 
     } 
    } 
    } 
}) 

と私は2つの次のコマンドを実行した場合、私は次のタスクが

grunt.registerTask('development', [ 
    'ngconstant:development' 
]); 

grunt.registerTask('staging', [ 
    'ngconstant:staging' 
]); 

grunt.registerTask('production', [ 
    'ngconstant:production' 
]); 

を登録されている、すべてが正常に動作してconfig.jsファイルが生成されます素晴らしいと思います。

grunt development 
grunt staging 

が、実行中grunt productionconfig.jsファイルを生成しません。なぜこれが起こっているのか分かりません。

+0

'grunt production'コマンドはエラーを返しますか?各ライブラリのどのバージョンを使用していますか?私は、あなたが提供したコードに基づいて、3つすべてのテストを迅速に行うことができました。 'grunt production --verbose'を実行して出力を共有できますか? – richleland

答えて

1

<%= yeoman.dist %>で始まるプロダクションでは、config.jsというファイルを<%= yeoman.app %>で始まるパスに生成し、ステージングするタスクは両方とも作成します。

2番目のパス(またはyeoman.dist)が存在するかどうかを確認します。

関連する問題