我有一个使用 Yeoman 和 Grunt 构建的 Angular 项目。每次如果我运行命令:
sudo grunt serve
应用程序是否正常启动但在 index.html 中从 bower_components 目录中删除了一些链接库。
外汇:
<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'
]);
});
但是现在,在 grunt serve 之后,我看到以下错误:
Running "serve" task
Warning: Task "scripinject" not found. Use --force to continue.
Aborted due to warnings.
怎么了?