I'm new Gulp user, and I try simple script to watch compass, but it didn't work. But when I just run gulp compass
gulp can compile it. Any ideas? Here 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']);
});
The Watch method is used to monitor your source files. When any changes to the source file is made, the watch will run an appropriate task. You can use the 'default' task to watch for changes to HTML, CSS, and JavaScript files.
The watch() API connects globs to tasks using a file system watcher. It watches for changes to files that match the globs and executes the task when a change occurs. If the task doesn't signal Async Completion, it will never be run a second time.
Gulp is just running as a never ending process. The way to abort a process is Ctrl + C .
IN GULP 4.X
You have to pass a function. The customary way of doing this in gulp 4.x is to pass a gulp.series()
invocation with only one task name. This returns a function that only executes the specified task.
gulp.task('watch', function() {
gulp.watch('./assets/scss/*.scss', gulp.series('compass'))
});
I changed gulp.watch
source to ./assets/**/*.scss
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With