Search code examples
angularjsboweryeoman-generator-angular

How can I force a Yeoman generated Angular project's bower.json to use the .min.js version?


I am currently working on a Yeoman generated Angular project.

I'd like to force bower.json to only utilize a dependency's *.min.js file rather than the full *.js version. I'm sure this is relatively easy to configure but I can't seem to figure it out.

For example, the following is being automatically injected:

<script src="bower_components/angular-chart/angular-chart.js"></script>

Instead of:

<script src="bower_components/angular-chart/angular-chart.min.js"></script>

Here's the full HTML from the relevant section:

<!-- 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-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/angular-utils-pagination/dirPagination.js"></script>
<script src="bower_components/spin.js/spin.js"></script>
<script src="bower_components/angular-spinner/angular-spinner.js"></script>
<script src="bower_components/d3/d3.js"></script>
<script src="bower_components/c3/c3.js"></script>
<script src="bower_components/angular-circular-navigation/angular-circular-navigation.js"></script>
<script src="bower_components/angular-chart/angular-chart.js"></script>
<!-- endbower -->
<!-- endbuild -->

Any assistance would be greatly appreciate. Thank you!


Solution

  • The idea is that when you are running it for development you want to use the non minified js so that if there are any issues you can read the source easily. To run for development you would just use:

    grunt serve
    

    Then when you are ready to deploy it you can just run:

    grunt
    

    This will produce a minified combined scripts/vendor.js. The ful build solution will be in the dist folder.