Search code examples
node.jsgulpgulp-watchgulp-sass

gulpfile only running once with watch


I have this as my gulpfile.js:

'use strict';

var gulp = require('gulp');
var sass = require('gulp-sass');

gulp.task( 'default', ['sass'] );

gulp.task('sass', function () {
  return gulp.src('./sass/theme.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./css'));
});

gulp.task('sass:watch', function () {
  gulp.watch('./sass/**/*.scss', ['sass']);
});

I works and compiles the sass however it stops running instead of watching? I am not too familiar with how gulp works so help would really be appreciated!

the output in console looks like this:

[13:14:29] Using gulpfile ~/public_html/mysite/gulpfile.js                                                                                                               
[13:14:29] Starting 'sass'...                                                                                                                                                               
[13:14:31] Finished 'sass' after 1.2 s                                                                                                                                                      
[13:14:31] Starting 'default'...                                                                                                                                                            
[13:14:31] Finished 'default' after 15 μs 

Solution

  • You haven't started sass:watch task.

    gulp.task( 'default', ['sass', 'sass:watch'] );