Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
Gulp 4 watch task only runs once

My gulpfile works well but when calling the watch task and then making a change to a watched file it only seems to run once and then no longer watches the file.

I have tried using callbacks but it doesn't seem to resolve my situation. I have recently changed from Gulp 3 to 4 and I am possibly missing a core piece of functionality.

// Load plugins
const gulp = require("gulp");
const sass = require('gulp-sass')(require('sass'))

// CSS task
function css() {
    process.chdir('./ui/src/sass/'); // Change current working directory
    return gulp.src('**/*.scss')
      .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
      .pipe(gulp.dest('../../dist/css/'));
}

// Watch files
function watchFiles() {
  gulp.watch( 'ui/src/sass/**/*.scss' ).on( 'change', gulp.series(css));
}

const watch = gulp.parallel(watchFiles);

// export tasks
exports.css = css;
exports.watch = watch;
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!