yeoman angular generator - generated index.html

2019-04-06 07:52发布

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.

标签: yeoman bower
1条回答
一夜七次
2楼-- · 2019-04-06 08:02

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.

查看更多
登录 后发表回答