The problem with browserSync does not track changes in files. The problem is noticed on Windows OS on OSX everything is working fine.

const gulp = require('gulp'); const browserSync = require('browser-sync'); const reload = browserSync.reload; const twig = require('gulp-twig'); const PATHS = { src: 'src/', dist: 'dist/' }; gulp.task('views',() => gulp.src(PATHS.src + 'views/*.twig') .pipe(twig()) .pipe(gulp.dest(PATHS.dist + '/views')) ); gulp.task('serve', ['views'], () => { browserSync({ notify: false, port: 9000, server: { baseDir: [PATHS.dist + 'views', PATHS.dist] } }); gulp.watch([PATHS.src +'views/**/*.twig'], ['views']).on('change', reload); 

At change of files * .twig task the views are not called

  • In views, gulp.src(PATHS.src + 'views/*.twig') works with files only from the views folder, and gulp.watch([PATHS.src +'views/**/*.twig'], ['views']) looks at the files in the views folder and under the folders, maybe there is an error here and you need to make gulp.src(PATHS.src + 'views/**/.*.twig') in the views tax. - stackanon
  • @stackanon, the fact is that if you run the gulp serve command and open the second terminal window and run the gulp views command there, it tracks this change and restarts the server and in the first terminal window it says that everything compiled. and when changing files, he does not want to run task views - Kirya
  • Try jsfiddle.net/4p82otjd gulp watch - stackanon starts

0