@Foxsy

Почему не работает gulp.watch?

Имеется такой gulpfile:

'use strict';
 
var gulp = require('gulp');
var sass = require('gulp-sass');
var smartgrid = require('smart-grid');

/* It's principal settings in smart grid project */
var settings = {
    outputStyle: 'scss', /* less || scss || sass || styl */
    columns: 12, /* number of grid columns */
    offset: '30px', /* gutter width px || % */
    mobileFirst: false, /* mobileFirst ? 'min-width' : 'max-width' */
    container: {
        maxWidth: '1200px', /* max-width оn very large screen */
        fields: '0' /* side fields */
    },
    breakPoints: {
        lg: {
            width: '1100px', /* -> @media (max-width: 1100px) */
        },
        md: {
            width: '960px'
        },
        sm: {
            width: '780px',
        },
        xs: {
            width: '560px'
        }
        /* 
        We can create any quantity of break points.

        some_name: {
            width: 'Npx',
            fields: 'N(px|%|rem)',
            offset: 'N(px|%|rem)'
        }
        */
    }
};

smartgrid('./sass', settings);

 
gulp.task('sass', function () {
  gulp.src('./sass/main.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./css'));
});
 
gulp.task('sass:watch', function () {
  gulp.watch('./sass/**/*.scss', ['sass']);
});


Возникает проблема 'sass:watch' errored after 9.17 ms

C:\Users\qqq\Downloads\proj>gulp sass:watch
Grid placed into ./sass/smart-grid.scss
Grid length is 9736 :)
Its work! Good day!
[04:44:08] Using gulpfile ~\Downloads\proj\gulpfile.js
[04:44:08] Starting 'sass:watch'...
[04:44:08] 'sass:watch' errored after 9.17 ms
[04:44:08] Error: watching ./sass/**/*.scss: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)
    at Gulp.watch (C:\Users\qqq\Downloads\proj\node_modules\gulp\index.js:31:11)
    at C:\Users\qqq\Downloads\proj\gulpfile.js:52:8
    at sass:watch (C:\Users\qqq\Downloads\proj\node_modules\undertaker\lib\set-task.js:13:15)
    at bound (domain.js:426:14)
    at runBound (domain.js:439:12)
    at asyncRunner (C:\Users\qqq\Downloads\proj\node_modules\async-done\index.js:55:18)
    at processTicksAndRejections (internal/process/task_queues.js:79:11)


Помогите пожалуйста исправить.
  • Вопрос задан
  • 156 просмотров
Решения вопроса 1
@L1nks
Замените
gulp.task('sass:watch', function () {
  gulp.watch('./sass/**/*.scss', ['sass']);
});

На
gulp.task('sass:watch', function () {
  gulp.watch('./sass/**/*.scss', gulp.series('sass'));
});
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы