Search code examples
javascriptgulpgulp-watch

My gulpfile can edit (change) and delete file, but dont copy new (add) files


I tried with gulp.watch and watch (gulp-watch) but when i add the new file, dont copy in dest.

How i can to do this?

Thnks!

PD: I use version 3.9.1

gulp.task('default', function () {
  for(var i = 0; i < origen_web.length ; i++) {
    var source = '../..' + '/dir' + '/**/*';
    var dist   = '../../dist';

    watch(source, function(obj){
      copyFiles(obj, source, dist);
    });
  }
}

function copyFiles(source, dist, obj) {

  gulp.src(source)
  .pipe(gulp.dest(dist));
}

Sorry, this is my code more and less.


Solution

  • Use absolute path to directories.

    Duplicate question of Gulps gulp.watch not triggered for new or deleted files?