joy
joy

Reputation: 3707

Gulp "watch" is not running the sub task "sass" on file change

I am using Gulp for watch and sass complier. When I start "watch" first time then "sass" complier runs and its create the css files as per given path. However when I change the .scss files then it doesn't call "sass" complier again. Following is is my these two tasks and variables.

gulp.task('sass', function () {
    gulp.src(config.sassPath)
        .pipe(sass())
        .pipe(gulp.dest(config.cssPath))
        .pipe(livereload());
});

gulp.task('watch', false, function () {
    livereload.listen(8189);
    gulp.src(config.watchPaths)
            .pipe(watch(config.watchPaths, function (event) {
                gulp.start( 'sass', 'js-hint', 'server','test');
                livereload();
            }))
            .pipe(livereload());
});

Following command i use to run "watch" task

gulp watch

I do see "watch" is reloading when I am changing the .scss file. Following is log for this.

[19:49:30] public/sass/html-controls.scss was changed
[19:49:30] /Users/dkuma204/Desktop/Dilip/Projects/OPEN/SourceCode/AWF/OPENApp/application/public/sass/html-controls.scss reloaded.

Not sure what I am missing here. Please help.

Upvotes: 0

Views: 760

Answers (1)

niba
niba

Reputation: 2911

Why it is so complicated? Try this:

gulp.task('watch', false, function () {
    livereload.listen(8189);
    gulp.watch(config.watchPaths,['sass', 'js-hint', 'server', 'test'])       
});

And your every task which requires livereload should have .pipe(livereload()) at the end. You shouldn't use gulp start. Here is one of comment from github discussion:

gulp.start is undocumented on purpose because it can lead to complicated build files and we don't want people using it

Upvotes: 1

Related Questions