Gulp Watch Isn't Watching

285 views Asked by At

I am just getting started with gulp and it is really cool. I am starting to use it by simply compiling Sass files (getting more complicated things working later). I want it to work like Sass's watch. Here is my gulpfile.js:

// Include Gulp
var gulp = require('gulp');

// Include Our Plugins
var sass = require('gulp-sass');
var watch = require('gulp-watch');
// Compile Our Sass
gulp.task('sass', function() {
    return gulp.src('sass/*.scss')
        .pipe(sass())
        .pipe(gulp.dest('css'));
});

// Watch Files For Changes
gulp.task('watch', function() {
    gulp.watch('scss/*.scss', ['sass']);
});

// Default Task
gulp.task('default', ['sass', 'watch']);

In theory, on gulp it should compile any sass file in the /sass/ directory then "watch" the directory for changes.

1

There are 1 answers

0
Zach Russell On BEST ANSWER

I figured it out. A syntax error:

// Watch Files For Changes
gulp.task('watch', function() {
    gulp.watch('scss/*.scss', ['sass']);
});

Should be:

// Watch Files For Changes
gulp.task('watch', function() {
    gulp.watch('sass/*.scss', ['sass']);
});