N
N
Nathan Stark2017-03-18 17:57:42
Pug
Nathan Stark, 2017-03-18 17:57:42

How to solve the problem of browserSync crashing if an error is made in the pug file?

Good day !
I can’t figure out how to solve such a problem, when I make a mistake in pug files, the browserSync server crashes, although if I make a mistake in less files, it just swears in the console but continues to work. How to ensure that the server does not crash with errors in pug files?

var gulp = require('gulp'),
    less = require('gulp-less'),
    pug = require('gulp-pug'),
    browserSync = require('browser-sync'),
    reload      = browserSync.reload;

gulp.task('connect', function() {
    browserSync({
        server: './assets',
        open: false,
        notify: false
    });
});

gulp.task('default', ['connect', 'watch']);

gulp.task('less', function () {
    gulp.src('less/index.less')
    .pipe(less())
    .pipe(gulp.dest('assets/css'))
    .pipe(reload({stream: true}));
});

gulp.task('pug', function () {
    gulp.src('pug/index.pug')
        .pipe(pug({
            pretty: true
        }))
        .pipe(gulp.dest('assets/'))
        .pipe(reload({stream: true}));
});

gulp.task('watch',function(){
    gulp.watch('less/*.less',['less']);
    gulp.watch('less/*/*.less',['less']);
    gulp.watch('pug/*.pug',['pug']);
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ivan1kazantsev, 2017-03-18
@MattLe

Picks up errors for itself ;)
https://www.npmjs.com/package/gulp-plumber

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question