Gulp Clock does not work

I am a new Gulp user and I am trying a simple script to view the compass, but it does not work. But when I just run gulp compass Gulp, it can be compiled. Any ideas? Here is my script:

 var gulp = require('gulp'), compass = require('gulp-compass'), // Compass gulp.task('compass', function() { gulp.src('./assets/scss/*.scss') .pipe(compass({ config_file: './config.rb', css: './assets/css', sass: './assets/scss' })) .pipe(gulp.dest('./assets/css')); }); // Default task gulp.task('default', function() { gulp.start('compass'); }); // Watch gulp.task('watch', function() { // Watch .scss files gulp.watch('./assets/scss/*.scss', ['compass']); }); 
+9
javascript compass-sass gulp
source share
3 answers

You have neglected the actual challenge of the watch task, this is not the same as gulp.watch. Your default gulp task should look like this:

 gulp.task('default', function() { gulp.start('compass'); gulp.start('watch'); }); 

but it should look like this:

 gulp.task('default', ['compass', 'watch']); 
+31
source share

I changed the source code of gulp.watch to ./assets/**/*.scss

+7
source share

In GULP 4.X

You must pass a function. The usual way to do this in gulp 4.x is to pass gulp.series() with only one task name. This returns a function that performs only the specified task.

 gulp.task('watch', function() { gulp.watch('./assets/scss/*.scss', gulp.series('compass')) }); 
0
source share

All Articles