各位求帮忙看下我的gulp为什么不会热更新

var gulp = require('gulp');
var htmlmin = require('gulp-htmlmin');
var cleanCSS = require('gulp-clean-css');
var uglify = require('gulp-uglify');
var pump = require('pump');
var clean = require('gulp-clean');
var livereload = require('gulp-livereload');
let connect = require("gulp-connect");

gulp.task('clean', function(cb) {
    setTimeout(()=>{
        pump([
            gulp.src('dist'),
            clean()
        ], cb)
    },100)
})
gulp.task('html',function(){
    return gulp.src('views/**/*.html')
    .pipe(htmlmin({collapseWhitespace:true}))
    .pipe(gulp.dest('dist/views'))
});
gulp.task('entry',function(){
    return gulp.src('index.html')
    .pipe(htmlmin({collapseWhitespace:true}))
    .pipe(gulp.dest('dist'))

});
gulp.task('css', function() {
    return gulp.src('statics/css/*.css')
      .pipe(cleanCSS({compatibility: 'ie8'}))
      .pipe(gulp.dest('dist/statics/css'))

  });
  gulp.task('js', function (cb) {
    pump([
          gulp.src('statics/js/*.js'),
          uglify(),
          gulp.dest('dist/statics/js'),
      ],
      cb()
    );
  });
  gulp.task('watch', function(cb) {
    livereload.listen(); //要在这里调用listen()方法
    gulp.watch('statics/js/*.js', gulp.series(['js']));
    gulp.watch('statics/css/*.css', gulp.series(['css']));
    gulp.watch("dist/**/*.*", gulp.series(["reload"]));
    cb()
  });

  gulp.task("server", function(cb){//配置热更新服务器
    connect.server({
        root: "dist",
        livereload: true,
        port: 8031
    })
    cb()
})

gulp.task("reload", function(cb){
    gulp.src("dist/**/*.html")
        .pipe(connect.reload());
        cb()
})
  gulp.task('default',gulp.series(['clean','entry','css','js','html','server','watch']));

谷歌浏览器下载了插件
image.png

插件这个状态应该是开启了把?我是两个状态都尝试了 改了css文件但是页面没有刷新 gulp有reload的进度显示
image.png

求帮忙看下 ~

阅读 241
评论
    0 个回答
    撰写回答

    登录后参与交流、获取后续更新提醒

    相似问题
    推荐文章