A
A
Artur Karapetyan2019-04-27 14:42:10
gulp.js
Artur Karapetyan, 2019-04-27 14:42:10

Why is gulp-pug not being updated?

Hello!
After a long wandering through all sorts of Vue / Angular cli, I had to return to Gulp. The problem is that when changing nested .pug files in the pug folder, the reload does not work (pug compiles to html, the problem is in the reload)

Folder structure:
5cc43f6ff0498862331009.png

Accordingly, only .pug files from the root should be compiled, changes can be observed in all files
Current config
var syntax = "scss";

gulp.task("browser-sync", function() {
  browserSync({
    server: {
      baseDir: "app"
    },
    notify: false,
    open: false
  });
});

gulp.task("pug", function() {
  gulp
    .src("app/pug/*.pug")
    .pipe(
      pug({
        doctype: "html",
        pretty: true
      })
    )
    .pipe(gulp.dest("app/"))
    .pipe(browserSync.stream());
});

gulp.task("watch", function() {
  gulp.watch("app/pug/*.pug", gulp.parallel("pug"));
});

gulp.task(
  "default",
  gulp.parallel("pug", "styles", "browser-sync", "watch")
);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Dobrin, 2019-04-30
@andreydobrin

I suggest doing this:

var browserSync  = require('browser-sync').create()
var bsConfig = {
    server: {
      baseDir: 'app'
    },
    notify: false,
    open: false
  }; 

gulp.task('watch', function(){
  browserSync.init(bsConfig);
  gulp.watch("app/pug/*.pug", gulp.parallel("pug"));
})

WatcherI suggest using it this way

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question