grunt.initConfig(configObject)
method.grunt.loadNpmTasks(nameOfPlugin)
method.grunt.registerTask(nameOfTask, [taskOne, taskTwo])
method. In the example above, we registered a default task so just running grunt
will execute the 'concat' and 'uglify' tasks.require(nameOfPlugin)
function.gulp.task(nameOfTask, callbackFn)
method.callbackFn
accepts another callback as a parameter or returns either a stream or a promise, the tasks can be run asynchronously. In the example above, the callbackFn
returns 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.js
file.scripts.js
file is then piped into the uglify plugin which will minify the contents of the file. client/dist/
directory using the gulp.dest(directoryPath)
method.gulp
command or you can call run the buildJS task directly by running gulp buildJS
.uglify
task might complete before the concat
task.Note: The example above is just to demonstrate how Gulp works. It would be much more common to have theconcat
anduglify
tasks defined in a single task, where the output ofconcat
would be piped touglify
.
gulp watch
will run the concat
task, then the uglify
task, then the sass
task, and finally the watch
task.gulp watch
will launch both the sass
and uglify
tasks at the same time. Since the compilation of SASS to CSS is not related to the minification of Javascript files, it is okay to start these tasks streams concurrently for faster execution time.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 (gulp.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.
--force
to continue the task and --stack
to output a stacktrace."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.