Using the output of one task as input for another

I have an html file containing links to js files. I want to parse it to get a list of related js and feed contrib-concat or any other task with them. Is there any convenient way to use the output of one grunt task as input for another?

+8
gruntjs
source share
1 answer

Use grunt.config . Here is an example:

 grunt.initConfig({ concat: { js: { src: ['default/concat/files/*'], dest: ['dist/javascript.js'], }, }, }); grunt.registerTask('extractjs', function() { /* Do the js extraction */ // Overwrite the concat.js.src with your extracted files. grunt.config(['concat', 'js', 'src'], extractedFiles); }); 

So, now when you run grunt extractjs concat , it will extract js and then concat extracted js files. Check out this task: https://github.com/cgross/grunt-dom-munger as it works on a similar goal. Here is another problem with lots of examples: https://github.com/gruntjs/grunt/issues/747

+4
source share

All Articles