2

what's the difference between using 'gulp default task' and 'run-sequence npm modules if i have two tasks to execute,the result was the same.so i have no idea why should use 'run-sequence'?

1.gulp default task
gulp.task('default',['task1','task2']);

2.'run sequence npm modules'
var runSequence = require('run-sequence'); gulp.task('default', function(callback) { runSequence('task1', 'task2', callback); });

i'm new in gulp,i saw the tutorial video online,and they teach to use 'run-sequence module' to advance the gulp skill,so i have got the question.

Joe
  • 31
  • 3

1 Answers1

3

In the first case, task1 and task2 are ran in parallel. In the second case, task2 is ran after task1 finishes.

You'd want to use run-sequence when a task depends on the result of another task.

To achieve this in gulp@3, you can also express this with task dependencies :

gulp.task('task2', ['task1'], function() {/* task definition */})

Here task1 is defined as a dependency for task2, so task2 won't execute until task1 is finished.

kombucha
  • 1,424
  • 1
  • 11
  • 19