1
votes

Have a problem occurs with gulp task using the Streamqueue, sass, plumber and watching it at the end. The Task is compiling production css-file from vendors css|scss files with my own.

gulp.task('fincss', function () {
    watch([workData.sassSrcFiles, workData.cssVendorSrcFiles], {}, function () {
        var convertFromScssToCssAndConcat =
            gulp.src(workData.sassSrcFiles)
                .pipe(plumber(error))
                .pipe(sass());

        var minifyAndConcatExistingCss =
            gulp.src(workData.cssVendorSrcFiles)
                .pipe(plumber(error));

        return sq({objectMode: true}, minifyAndConcatExistingCss, convertFromScssToCssAndConcat)
            .pipe(concat('final.min.css'))
            .pipe(uglifycss())
            .pipe(gulp.dest(workData.cssDest))
            .pipe(livereload());
    });
});

var error = function (e) {
    console.error('Error in plugin "' + e.plugin + '"');
    console.error('   "' + e.message + '"');
    console.error('   In file "' + e.fileName + '", line "' + e.lineNumber + '".');
    console.log('--------------------------------------');
    console.log(e);
};

But when error in scss file then breaking task. And any experiments with plumber which provides in Internet doesn't helps me anyway. Something like inserting plumber() before concat, or using this.emit('end') in the error handler do nothing.

In other my tasks like

gulp.task('toHtml', function () {
    watch(workData.pugSrcFiles, {}, function (e) {
        message('Start generating template.');
        gulp.src([workData.pugSrcFiles, '!' + workData.pugSrc + '_*.pug'])
            .pipe(plumber(error))
            .pipe(pug({pretty: true}))
            .pipe(gulp.dest(pubDir))
            .pipe(livereload());
    });
});

all works pretty good and without breaking task.

Help, please.

1

1 Answers

0
votes

You can use stream-series to replace streamqueue.

change your config file to:

var series = require('stream-series');

gulp.task('fincss', function () {
    watch([workData.sassSrcFiles, workData.cssVendorSrcFiles], {}, function () {
        var convertFromScssToCssAndConcat =
            gulp.src(workData.sassSrcFiles)
                .pipe(plumber({errorHandler: function(error) {
                     convertFromScssToCssAndConcat.emit('end')  // important
                 }}))
                .pipe(sass());

        var minifyAndConcatExistingCss =
            gulp.src(workData.cssVendorSrcFiles)
                .pipe(plumber(error));

        return series(minifyAndConcatExistingCss, convertFromScssToCssAndConcat)
            .pipe(concat('final.min.css'))
            .pipe(uglifycss())
            .pipe(gulp.dest(workData.cssDest))
            .pipe(livereload());
    });

});