gulpgulp-sassgulp-dest

Glob watch multiple files, process one


I use Gulp 4 with gulp-sass. What I try to do is the following.

gulp.watch('custom/components/**/*.scss', style);
function style() {
  return gulp
    .src()
    .pipe(sass())
    .on('error', sass.logError)
    .pipe(gulp.dest('assets/css/dist'));
}

Solution

  • I just figure it out. It's possible to do it like this.

    let watcher = gulp.watch(css.watch);
    
    watcher.on('change', function(path) {
      console.log(path);
      style();
    }