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.
なにが問題ですか?