2016-11-08 8 views
0

私は最初のSPAをAngularで作成し、SpringBoot Rest APIを使用しています。Angular SPAで単純な "build"を作成する方法

私が必要とするのは、Maven for Javaプロジェクトのような単純な「ビルド」プロセスを作成することです。そのため、さまざまな環境定数を処理できます。簡単にすることは可能ですか?私は非常に大きなconfig jsを見てきました。これは簡単なプロジェクトです。

私は私のapp.js

angular.module('app', [ 'ui.router', 'ngCookies', 'ngMessages', 'ngStorage', 'ngAnimate', 'datatables', 
     'checklist-model', 'pascalprecht.translate', 'ui.bootstrap', 'oitozero.ngSweetAlert', 'ngSanitize', 
     'angucomplete-alt', 'localytics.directives', 'angular-peity']) 
      .constant('config', { 
       appName : 'MyApp', 
       appVersion : '1.0.0', 
       apiUrl : 'http://localhost:8080/rest/v1/', 
       auth : { 
        url : 'http://localhost:8080/oauth/token', 
        clientId : 'myAppOuath2', 
        header : 'Basic c29mdGFs123456F1dGgyOlh6NnFnamhwwxx=', 
        grantType : 'password' 
       } 
      }) 
... 

でこれを持っていると私はこのようなワイルドカードを持つURLを自動化したい:

... 
apiUrl : '{apiUrl}', 
auth : { 
    url : '{authUrl}', 
    clientId : '{clientId}', 
    header : '{authHeader}', 
    grantType : 'password' 
} 

感謝を!

+0

grunt-preprocess:https://github.com/jsoverson/grunt-preprocessを参照してください。 –

答えて

0

私はmavenに慣れていません。私はいつもGulpやGruntを使ってSPAのアプリケーションを構築してきました。ビルドするには

ngconstant: { 
    options: { 
    name: 'config', 
    space: ' ', 
    dest: 'app/config.js' 
    }, 
    local: { 
    constants: { 
     ENV: 'local' 
    } 
    }, 

    dev: { 
    constants: { 
     ENV: 'dev' 
    } 
    } 
} 

あなたは、いくつかのconfig.jsを(うなり声と私はngconstantプラグインを使用)を生成することができます

grunt.registerTask('build', function(target) { 
    grunt.task.run([ 
     'ngconstant:' + target 
    ]) 
}) 

$ grunt build:local

config.jsが生成されると、次のステップは、あなたのアプリにそれを含めてください。

angular.module('myApp', ['config'])

+0

MavenはJavaプロジェクト用です。 JSとは関係ありません。その "config.js"の例を私に見せてもらえますか? –

関連する問題