yeoman angular generator - generated index.html

时间秒杀一切 提交于 2019-12-09 15:34:23

问题


Last day I was in process of updating Angular library in my project from 1.0.7 to 1.2.6, to do this, I updated my yeoman generator and generated application again.

After this, I started browsing generated files to get hang of the changes and I noticed something new in index.html file.

    <!-- build:js scripts/vendor.js -->
    <!-- bower:js -->
    <script src="bower_components/jquery/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-resource/angular-resource.js"></script>
    <script src="bower_components/angular-cookies/angular-cookies.js"></script>
    <script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
    <script src="bower_components/angular-route/angular-route.js"></script>
    <!-- endbower -->
    <!-- endbuild -->

I know that <!-- build:js scripts/vendor.js --> and <!-- endbuild --> comments are used by grunt-usemin task, but what is the purpose of <!-- bower:js --> and <!-- endbower -->? I can't find any mention of it in bower documentation posted on main page.


回答1:


That's grunt-bower-install, which was added to v0.7.0 of the Angular generator.

Initially, when you scaffolded the application, it automatically wired up your Bower packages to your index.html file. Going forward, after installing or un-installing a Bower package, you can run grunt bower-install to update the references inside of your <!-- bower:* -->...<!-- endbower --> blocks.

Also, notice in the <head> section, there is a <!-- bower:css --> block, which will reference your Bower packages' CSS files.

Update - 8/7/2014

If grunt-bower-install doesn't work try(in order): grunt wiredep, grunt bower-install, grunt bowerInstall

Make sure to bower install --save to add it to bower.json as a dependency.



来源:https://stackoverflow.com/questions/20783199/yeoman-angular-generator-generated-index-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!