Creating tasks in gulp.js
We are going to create a first task to greet our readers. Again, let us go through a simple stepwise procedure so that nothing is missed out.
1. First, let us write some pluggable code in gulpfile.js
, as follows:
const gulp = require('gulp'); gulp.task('default', () => { console.log("Greetings to Readers!"); })
In preceding snippet, the task method of gulp module requires two parameters. The first one is name of task as a string and second parameter is callback where we can write the actual logic behind the specific task.
2. Go back to the Terminal and run the gulp
command. You will receive the following output:
Now, let's add a little complexity by adding one more task and using it as a dependency to the previous one:
const gulp = require('gulp'); gulp.task('default', ['dependent-task'], () => { console.log("Greetings to Readers!"); }) gulp.task('dependent-task', () => { console.log("Greetings to all!"); })
3. On executing the preceding code using...