Well, after some research and help from the grunt-contrib maintainers, I rewrote this task that I have:
grunt.registerMultiTask('multicss', 'Minify CSS files in a folder', function() { grunt.file.expandFiles(this.data).forEach(function(file) { var minified = grunt.helper("mincss", grunt.file.read(file)); grunt.file.write(file, minified); grunt.log.writeln("Minified CSS "+file); }); });
In it:
grunt.registerMultiTask('multicss', 'Minify CSS files in a folder', function() { var count = 0; grunt.file.expandFiles(this.data).forEach(function(file) { var property = 'mincss.css'+count+'.files'; var value = {}; value[file] = file; grunt.config(property, value); grunt.log.writeln("Minifying CSS "+file); count++; }); grunt.task.run('mincss'); });
No changes to the configuration file are required. In the new part of the code, the task itself is used, and not the assistant who left.
This may not be the best approach, and Grunt 0.4.0 may change the game again, but now it works with Grunt 0.3.15 and grunt-contrib 0.2.
GriffonRL
source share