Answer the question
In order to leave comments, you need to log in
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
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}));
});
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);
});
default
a task
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question