Gulp -watch only works on first start

What am I doing?

  • Run gulp(SCSS files are being processed, I get a CSS file)
  • I am changing any SCSS file again

Expected:

  • The CSS file from 1. is updated with the changes from 2.

What's happening?

  • CSS file from 1. does not change

Command line output:

$ gulp
[09:24:28] Using gulpfile c:\Users\User\_dev\github\project\gulpfile.js
[09:24:28] Starting 'sass'...
[09:24:28] Finished 'sass' after 98 ms
[09:24:28] Starting 'default'...
[09:24:28] Finished 'default' after 7.31 μs
[09:24:35] sass-watch saw _base.scss was changed
[09:25:39] sass-watch saw _base.scss was changed

gulpfile.js:

gulp.task('sass', function() {
    watch({ glob: 'css/**/*.{scss,sass}', name: 'sass-watch'})
        .pipe(plumber())
        .pipe(sass())
        .pipe(gulp.dest('css'))
});

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

Notes:

The method of transferring the source files does not matter. The result remains unchanged when used.gulp.src()

+4
source share
1 answer

I do not think your sass task is spelled correctly.

Try something like this:

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

gulp.task('sass', function () {
    gulp.src('PATH-TO-SASS-FILES/*.scss')
        .pipe(sass())
        .pipe(gulp.dest('./css'));
});
0
source

Source: https://habr.com/ru/post/1546397/


All Articles