Grunt is removing the helpers and this already happened in grunt-contrib.
However I have a Grunt file relying on some custom tasks calling some of those helpers. Without helpers it breaks. I am just wondering what should be the correct way to replace those.
I get it will be by calling the tasks directly in some way but I am not sure how. An example would help a lot since Grunt documentation is not updated yet.
Thanks.
Ok after some research and the help of the maintainers of grunt-contrib, I rewrote that task 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);
});
});
Into this:
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 other change needed in the config file. The new piece of code makes use of the task itself instead of the helper that is gone.
This might not be the best approach and Grunt 0.4.0 might change the game again, but it does work right now with Grunt 0.3.15 and grunt-contrib 0.2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With