0

Yeoman と Grunt でビルドされた Angular プロジェクトがあります。コマンドを実行するたびに:

sudo grunt serve 

アプリは正常に起動されますが、index.html では、bower_components ディレクトリからいくつかのリンクされたライブラリが削除されています。

FXP:

<script src="bower_components/spin.js/spin.js"></script>

したがって、テストを続行する前に、git の index.html ファイルの変更を毎回元に戻す必要があります。

この厄介な問題を解決するにはどうすればよいですか?

助けてくれてありがとう。

編集:

私は次のことを試しました:

インストール済み:

npm install grunt-script-inject

GrunFile.js

 // Automatically inject Bower components into the app
    wiredep: {
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        ignorePath: new RegExp('^<%= yeoman.app %>/|../')
      },
    scriptinject: {
      dev: {
         srcs: ['<%= yeoman.client %>/bower_components/path/to/src/plugin.js',
                '<%= yeoman.client %>/bower_components/path/to/src/plugin2.js'] ,//order is important if this sciprt will be concated and minified
         html: '<%= yeoman.client %>/index.html', //file that as the block comment to look for a place to insert the script tags
         without: '<%= yeoman.client %>/' //this script will be used to remove this block of string of script tag file location
        }
      }
    },

 grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'wiredep',
      'scripinject',
      'concurrent:server',
      'autoprefixer',
      'connect:livereload',
      'watch'
    ]);
  });

しかし今、うなり声を上げた後、次のエラーが表示されます。

Running "serve" task
Warning: Task "scripinject" not found. Use --force to continue.

Aborted due to warnings.

なにが問題ですか?

4

2 に答える 2

1

同様の問題がありました。index.html に次のコードを追加しました。

<script src="bower_components/highcharts-release/highcharts.js"></script>
<script src="bower_components/highcharts-release/modules/heatmap.js"></script>

grunt serveまたはコマンドを実行するたびにgrunt build、うなり声はそれを次のように書き直しました。

<script src="bower_components/highcharts-release/highcharts.js"></script>
<script src="bower_components/highcharts-release/highcharts-more.js"></script>
<script src="bower_components/highcharts-release/modules/exporting.js"></script>

だから私はbower_components/highcharts-release/bower.jsonファイルを調べて見ました:

{
  "name": "highcharts",
  "version": "v4.1.4",
  "main": [
    "highcharts.js",
    "highcharts-more.js",
    "modules/exporting.js"
  ]
}

私はそれを次のように変更しました:

{
  "name": "highcharts",
  "version": "v4.1.4",
  "main": [
    "highcharts.js",
      "modules/heatmap.js"
  ]
}

そして今、すべてが順調です。これがかなり遅い答えであっても、それが誰かを助けることを願っています。

于 2015-04-13T08:54:40.083 に答える
1

--s in bower install コマンドを使用して解決しました

そう:

bower install --save  angular-translate

正常に動作します。

ドキュメントは次のとおりです。

http://bower.io/docs/api/#install

于 2014-10-14T08:37:45.213 に答える