1

I am using web yeoman.

In my applications index.html file I have this script includes.

I would like to know what these <!-- build:js ... --> mean and from which tool they originate?

I would also be grateful about any source link.

My problem is that I plan a very modularized angularjs app and I do not want to manually add 200 .js files to this index.html file.

Maybe this can be configured that during compiling those script entries can be copied over with a clever algo depending on my app folder structure...

<!-- build:js({.tmp,app}) scripts/scripts.js -->
    <script src="scripts/app.js"></script>
    <script src="scripts/controllers/main.js"></script>
    <script src="scripts/services/factory1.js"></script>
<!-- endbuild -->
Pascal
  • 12,265
  • 25
  • 103
  • 195

1 Answers1

1

The build blocks are from grunt-usemin. It will not automatically scan and add files from a directory.

You can use a task like grunt-include-source to prep the HTML with the files from your scripts directory tree and then run usemin to concat and uglify them.

The grunt-include-source github page (linked in the last paragraph) contains examples of Gruntfile configurations to update the HTML. Your main challenge will be the src to dest juggle as the HTML is updated by multiple tasks. In the scope of things, compared to dealing with 200+ files, that should still be easier. The downside, of course, is that if you have any orphan files in your list of 200+...they will still get included and sent.

You can also see these StackOverflow questions where similar questions have been asked:

  1. can grunt automatically include all my js in index.html?
  2. How to include scripts automatically in a yeoman/grunt project?
Community
  • 1
  • 1
Matthew Bakaitis
  • 11,600
  • 7
  • 43
  • 53
  • About the orphan files, could I not create a grunt task which removes the content between the build blocks and THEN read all .JS files from modules/**/*.JS to add them within the build blocks? Then I would have no orphans right? – Pascal Jun 04 '14 at 18:45
  • Sure. I think there are several reasonable approaches to cleaning up orphan files. Use the one that makes the best sense for your project. :) – Matthew Bakaitis Jun 04 '14 at 18:47