K
K
Kiryan Goryachev2019-01-08 17:45:18
gulp.js
Kiryan Goryachev, 2019-01-08 17:45:18

Gulpfile.js doesn't work watch, what's wrong?

I compile scss to css using Gulp. Everything was great, but when I started a new project, I found that the Gulpfile.js code, which worked from project to project, stopped working.

'use strict';
 
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
 
gulp.task('sass', function () {
  gulp.src('./assets/scss/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(sass({outputStyle: 'compressed'}))
    .pipe(autoprefixer({
      browsers: ["last 50 versions", "ie >= 9"],
      cascade: false
  }))
    .pipe(gulp.dest('./assets/css'))
    
});

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

When I start watch, after changing scss the script works, but nothing happens after starting 'sass'. If you run 'sass', then the console responds
The following tasks did not complete: sass
Did you forget to signal async completion?.

Googling, I found information about gulp.parallel and series in Gulp v4, but did not understand what was happening. Please help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Martovitskiy, 2019-01-08
@kirseich

The fourth version introduced a syntax that allows you to specify the order in which tasks are started.
Try like this.

gulp.task('watch', function() {
    gulp.watch('./assets/scss/*.scss',  gulp.series('sass'));
});

here is the video . It details what has changed and why.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question