Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the second argument of a gulp task mean:

Tags:

gulp

I'm looking for an answer to this, doesn't have to be in depth or great detail. Just want to know exactly what happening with the sequence of the task.

gulp.task('name',['*this right here*'], function() {
    // content
});

Does it mean do this task in consecutively namely with this definition task? Why this came up for me is because in my gulpfile.js I'm using gulp-inject for app files and wiredep for vendor dependencies. If this is wrong or either one will do then great, Im under the impression not though. What I have so far is below.

//originally i didn't have bower here in the array in 2nd param.
gulp.task('index', ['bower'], function() {
  var target = gulp.src(files.app_files.target);
  var sources = gulp.src(files.app_files.sources, {
    read: false
  });

  return target.pipe(inject(sources))
    .pipe(gulp.dest('./dist'));
});


gulp.task('bower', function() {
  return gulp
    .src(files.app_files.target)
    .pipe(wiredep())
    .pipe(gulp.dest('dist/'));
});


<head>
  <meta charset="UTF-8">
  <title>Example Page</title>
  <!-- Vendor Files  -->
  <!-- bower:css -->
  <!-- endbower -->
  <!-- App Files -->
  <!-- inject:css -->
  <!-- endinject -->
</head>

<body>
  <navigation></navigation>
  <div ui-view></div>
  <footer-area></footer-area>
  <!-- Vendor Files -->
  <!-- bower:js -->
  <!-- endbower -->
  <!-- App Files -->
  <!-- inject:js -->
  <!-- endinject -->
</body>

Update

gulp.task('index', function() {
  var target = gulp.src(files.app_files.target);
  // It's not necessary to read the files (will speed up things), we're only after their paths:
  var sources = gulp.src(files.app_files.sources, {
    read: false
  });

  return target
    //here instead of breaking into new task i piped inject and wiredep, works great
    .pipe(inject(sources))
    .pipe(wiredep())
    .pipe(gulp.dest('./dist'));
});
like image 496
alphapilgrim Avatar asked May 06 '16 22:05

alphapilgrim


1 Answers

That's an array of tasks to run before your task. Also, note those tasks (all the ones in the array, in you case there's only bower) run in parallel.

If you need some in sequence. Consider gulp-sequence

like image 54
Bruno Garcia Avatar answered Oct 18 '22 16:10

Bruno Garcia