M
M
Martovitskiy2019-02-12 23:26:06
gulp.js
Martovitskiy, 2019-02-12 23:26:06

Why doesn't reload html work?

I catch the error TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function. Received type undefined
As far as I understand, it appears because of gulp.watch("*.html").on("change", browserSync.reload);
If I just write gulp.watch("*.html", browserSync.reload); there is no error, but reload does not work either.
gulpfile.js

const
  gulp          = require('gulp'),
  sass          = require('gulp-sass'),
  browsersync   = require("browser-sync").create(),
...

function browserSync(done) {
  browsersync.init({
    injectChanges: true,
    server: {
      baseDir: "./"
    },
    port: 3000,
    notify: false
  });
  done();
}

function watchFiles(done) {
  gulp.watch('assets/sass/**/*.sass', gulp.parallel(gulpSass));
  gulp.watch('assets/css/**/*.css', browserSync.reload);
  gulp.watch('assets/js/**/*.js', browserSync.reload);
  gulp.watch("*.html").on("change", browserSync.reload);
  done();
}

const watch = gulp.parallel(watchFiles, browserSync);


exports.watch = watch;

Who faced? Or maybe I'm doing something wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question