grunt.registerTask(nameOfTask, [taskOne, taskTwo])method. In the example above, we registered a default task so just running
gruntwill execute the 'concat' and 'uglify' tasks.
callbackFnaccepts another callback as a parameter or returns either a stream or a promise, the tasks can be run asynchronously. In the example above, the
callbackFnreturns a stream.
gulp.src(globs)specifies the source files we want to run the tasks on. The globs parameter can be a string or an array of strings. This method allows us to pipe files matching the glob(s) to plugins.
scripts.jsfile is then piped into the uglify plugin which will minify the contents of the file.
client/dist/directory using the
gulpcommand or you can call run the buildJS task directly by running
uglifytask might complete before the
Note: The example above is just to demonstrate how Gulp works. It would be much more common to have the
uglifytasks defined in a single task, where the output of
concatwould be piped to
gulp watchwill run the
concattask, then the
uglifytask, then the
sasstask, and finally the
gulp watchwill launch both the
Note: 1. The next version of Grunt will also use the orchestrator module so the speed advantage that Gulp offers might be offset. 2. To replace the somewhat convoluted sequencing through dependencies, the next version of Gulp will use the undertaker module which will allow you to specify whether you want to run tasks in sequence (
gulp.series) or in parallel (
Note: If this is at all confusing, you've run into one of the cons of Gulp. Gulp does require some understanding of streams and if you come from a non-Node.js background, this may be another concept you have to learn.
Note: These results should be taken with a grain of salt because the way both task runners measure time may be slightly different. However, in researching this topic, it seems that other developers have seen similar outcomes. I've included those articles in the Additional Reading section in bold.
"There are three kinds of lies: lies, damned lies and statistics." - Mark Twain
Note: Statistics can be deceptive. For example, if Gulp had more downloads than Grunt the past month, that may be more indicative of Grunt's market saturation rather than Gulp's popularity. Stats over a shorter period of time are even less reliable. I will just present the numbers and you may decide if they are significant in your decision.
Note: Grunt's statistics start from it's release in 11/2012 to 06/2016. Gulp's statistics start from it's release in 07/2013 to 06/2016.
Note: Watching a repository means all pull requests and issues will be show up in the news feed. Starring a repository is meant to track and show appreciation for a project without receiving activity notifications. Forking a repository copies a project and suggested changes to the original project can be made via a pull request.
Articles in bold contain speed comparisons.