改变这个:
gulp.watch('./src/sass/*.scss', gulp.series('sass'), browserSync.reload);
至:
gulp.watch('./src/sass/*.scss', gulp.series('sass', browserSync.reload));
也在这:
gulp.task('sass', function(cb) { pump([ gulp.src('src/sass/*.scss'), // don't call browserSync.stream() before sass() // plus you already have it in your scss watch to reload // so either move this to the end - after gulp.dest - and remove it from the watch // or remove it from here and leave in the watch // browserSync.stream(), sass().on('error', sass.logError), cleanCSS(), gulp.dest('dist/css') ], cb; ); });
// in your watch task: gulp.watch("./src/*.html", { events: 'all' }, function(cb) { browserSync.reload(); cb(); }); gulp.task('html', function(cb) { pump([ gulp.src('src/*.html'), gulp.dest('dist'), // browserSync.stream() ], cb ); });