N
N
ne_pes2020-04-30 16:32:43
gulp.js
ne_pes, 2020-04-30 16:32:43

Why is gulp task not working?

Why is gulp prettyHtml not called when calling gulp pug?

gulp.task('prettyHtml', function () {
    gulp.src('app/*.html')
        .pipe(prettyHtml({indent_size: 4}))
        .pipe(gulp.dest('app/'));
});

gulp.task('pug', function(){
    return gulp.src("app/pug/**/*.pug")
        .pipe(plumber())
        .pipe(pug({
            pretty: true
         }))
        .pipe(gulp.dest("app/"))
        .pipe(prettyHtml())
        .pipe(browserSync.reload({stream: true}));
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Viktorovich, 2020-05-02
@ne_pes

gulp.task('pug', function(){
    return gulp.src("app/pug/**/*.pug")
        .pipe(plumber())
        .pipe(pug({
            pretty: true
         }))
        .pipe(prettyHtml({indent_size: 4}))
        .pipe(gulp.dest("app/"))
        .pipe(browserSync.reload({stream: true}));
});

A
Andrey Pastukhov, 2020-04-30
@tyllo

Try something like this

const config = {
  html: ['app/*.html'],
  pug: ['app/pug/**/*.pug'],
};

const reload = () => browserSync.reload({ stream: true });

gulp.task('prettyHtml', function () {
    gulp.src(config.html)
        .pipe(prettyHtml({indent_size: 4}))
        .pipe(gulp.dest('app/'));
});

gulp.task('pug', function() {
    return gulp.src(config.pug)
        .pipe(plumber())
        .pipe(pug({ pretty: true }))
        .pipe(gulp.dest("app/"));
});

gulp.task('default', ['pug','prettyHtml'], function () {
  gulp.watch(config.pug, ['pug']).on('change', reload);
  gulp.watch(config.html, ['prettyHtml']).on('change', reload);
});

And you need to run defaulta task

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question