D
D
Dima2018-01-10 16:14:23
Pug
Dima, 2018-01-10 16:14:23

How to make a task in gulp to process pug modules?

There are pug pages of the site and a folder with modules that are embedded in pages using include.
If I change something in a module, gulp doesn't see it and I have to compile the pug files and html files to the root each time. What can be done?
Here is my gulpfile

var pug = require("gulp-pug");

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

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
deeppines, 2018-01-10
@qpz

var reload = browserSync.reload;
var runSequence = require('run-sequence');

gulp.task('pug', function () {
    return gulp.src('source/*.pug')
            .pipe(pug({pretty: true}))
            .pipe(gulp.dest(''))
    });
    
gulp.task('watch', function(){
    $.watch('source/**/*.pug ', function(event, cb) {
            return runSequence('pug', reload);
        });
}

E
Egor Zhivagin, 2018-01-10
@Krasnodar_etc

So... google gulp-watch and screw it up. Now your task fulfills 1 time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question