3

I want to run ng-annotate via grunt on all my project's angular files.
Could not find this option.

I only have the option annotate by specify file name.

ngAnnotate: {
        dist: {
            files: {
                'output_file_name.js': ['input_file_name'],
            },
        }
    }

I need something more generic that would run recursively on a specific directory.

chenop
  • 4,743
  • 4
  • 41
  • 65

1 Answers1

10

You can use the other configuration to go through folders and annotate each file which will be outputted in a *.annotated.js file.

ngAnnotate: {
    dist: {
        files: [{
                expand: true,
                src: ['**/*.js', '!**/*.annotated.js'],
                ext: '.annotated.js',
                extDot: 'last'
            }],
    }
}
Mike Vranckx
  • 5,557
  • 3
  • 25
  • 28
  • Thanks @Mike, But Isn't it will concat all *.js files into output_file_name.js? – chenop Oct 02 '15 at 07:45
  • Indeed, I've updated my answer which will annotate each file separately and write an `.annotated.js` version of it – Mike Vranckx Oct 02 '15 at 09:02
  • Thanks @Mike, just want to emphasis that there are 2 things important to notice: 1. the array form of "files", 2. the src: ['**/*.js'] form for multiple files – chenop Oct 02 '15 at 15:21