Javascript Task Runners
Hello Guys today I will tell what are JavaScript Runners and how it will help you build your single page web application.
Task runners are a set of tools to make build operation clean and well documented. They provide helpers to manage operations on the project file system via the command line. Task runners will do all the repetitive task like minification, compilation, unit testing, linting etc in less time. In short task runners will do all the mundane work for you and your team in no time.
In this post we will see 4 JavaScript Task runners Grunt, Cake, Gulp and Broccoli.
Grunt
One of the most used task runner is Grunt. It was created by Ben Alman in Node.js. Grunt is a JavaScript task runner, a tool used to automatically perform frequently used tasks such as minification, compilation, unit testing, linting, etc. It uses a command-line interface to run custom tasks defined in Gruntfile file.
Plugins are based on configuration via a JavaScript object. Unless you want to write your own plugin, you mostly write no code logic. The community is very active and you will find a lot of resources about Grunt.
Learn Grunt here.
Grunt has tons of plugins, everyday a new plugin is developed. You can see all the plugin list here.
Cake
Cake is only supported with coffeescript. It is exactly opposite to grunt. Cake is useful in small task in a very straightforward way. It also requires Cakefile to describe the task. There is no plugin system like grunt so you must write all the logic yourself.
In short, it is perfect for small task and does not require any dependencies if you work with coffeeScript. But if you use this for large task it will make you life difficult.
I am not sure it is used much now-a-days as it can’t handle heavy task.
Gulp
It works same as grunt, but makes things little easier by replying on code logic based on pipes. The idea is that your code is a list of files that require a series of operation to be applied in a gulpfile.js file. Each operation is piped to next one.
It has also plenty of plugin like grunt, but the code is flexible and less code is required compared to grunt. On the counterpart it doesn’t provide clean configuration file and, for the moment, the community is less active.
Learn gulp here.
Broccoli
Broccoli follows gulp principle, tasks based on code logic and plugin system for helpers. It uses filters instead of pipe that you can apply to tree of file. You need to select folder and then apply the functions of plugin to it in a broccoli.js file. Broccoli relies more on the command line for parameters.
It is not completely stable, but it produces the most concise code of all. But its community is less active compared to grunt and gulp.
Download and learn Broccoli here.
So if you ask me which is the best task runner, I would say broccoli is best, but the only reason you cannot use it widely is only because it is not stable. So grunt is the better choice, because grunt is completely stable and there are lots of plugin available fo you to use. But if you want a smaller task to be handled use gulp.