[英]Grunt not updating Script Tags in Angularjs App
I have two Angularjs projects scaffolded using Yeoman. 我有两个使用Yeoman搭建的Angularjs项目。 The first project is a library that has been scaffolded with the Angular Library Generator while the second is a full app scaffolded with the Yeoman Angular Generator . 第一个项目是使用Angular Library Generator搭建的库 ,第二个项目是使用Yeoman Angular Generator搭建的完整应用程序。 I want the App to use the Library so in the App directory I installed the library using Bower: 我希望应用程序使用库,因此在App目录中,我使用Bower安装了该库:
bower install github-id/library-name --save
Although the library is not registered with Bower I can still install it with my Github Id and library name. 尽管该库未在Bower中注册,但我仍然可以使用我的Github ID和库名称进行安装。 The bower_components
directory now holds the library and its dependencies but when I run Grunt using grunt serve
or just grunt
, the App's Index.html
file is not being updated with the library, although you can see that other modules such as lodash
, for example, are there: 该bower_components
目录现在拥有图书馆和它的依赖,但是当我使用运行咕噜grunt serve
或只是grunt
,应用程序的Index.html
文件不被与库更新,虽然可以看到其他模块,如lodash
,例如,在那儿:
<!-- build:js(.) scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-messages/angular-messages.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-touch/angular-touch.js"></script>
<script src="bower_components/lodash/lodash.js"></script>
<!-- endbower -->
<!-- endbuild -->
And if I try to add the library as a script tag manually, Grunt
subsequently removes any tags that I add. 而且,如果我尝试手动将库添加为脚本标签, Grunt
随后会删除我添加的所有标签。
Can anyone tell me why the tags are not being added? 谁能告诉我为什么不添加标签?
Thanks! 谢谢!
The problem was solved by looking in the bower.json file of library project in the bower_components
directory of my app. 通过在我的应用程序的bower_components
目录中bower_components
库项目的bower.json文件,可以解决该问题。 In the bower.json file, the path given under the "main" field was incorrect. 在bower.json文件中,“主”字段下给出的路径不正确。 Once this was fixed then the library was added to the `index.html correctly. 解决此问题后,库便被正确添加到`index.html。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.