zoukankan      html  css  js  c++  java
  • gulp 4.0 提示 Error: watching index.html: watch task has to be a function 解决办法

    gulp 4.0 提示 Error: watching index.html: watch task has to be a function 解决办法

    原文链接:https://blog.csdn.net/mlonly/article/details/85917261

    提示:Error: watching index.html: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)

    gulp 4.0之后不能按照之前的写法了  大有改变

    4.0之前的写法

    Gulp.watch(“监听的文件”,[任务名字符串])

    1.  
      // gulp.task("watch",function(){
    2.  
      // gulp.watch("index.html",["copyindex"]);
    3.  
      // gulp.watch("js/**/*",["copyjs"]);
    4.  
      // gulp.watch("css/**/*.scss",["copycss"]);
    5.  
      // gulp.watch("html/**/*",["copyhtml"]);
    6.  
      // gulp.watch("php/**/*",["copyphp"]);
    7.  
      // gulp.watch("img/**/*",["copyimg"]);
    8.  
      // })

    4.0之后的写法

    Gulp.watch(“监听的文件”,回调函数)。

    gulp.task("watch-all",async ()=>{

    gulp.watch("index.html",async ()=>{
    gulp.src("index.html")
    .pipe(gulp.dest("D:\myphp_www\PHPTutorial\WWW\baidu"));
    });
    gulp.watch("js/**/*",async ()=>{
    gulp.src("js/**/*")
    .pipe(gulp.dest("D:\myphp_www\PHPTutorial\WWW\baidu\js"));
    });
    gulp.watch("css/**/*.scss",async ()=>{
    gulp.src("css/**/*.scss")
    .pipe(sass())
    .pipe(gulp.dest("D:\myphp_www\PHPTutorial\WWW\baidu\css"));
    });
    gulp.watch("html/**/*",async ()=>{
    gulp.src("html/**/*")
    .pipe(gulp.dest("D:\myphp_www\PHPTutorial\WWW\baidu\html"));
    });
    gulp.watch("php/**/*",async ()=>{
    gulp.src("php/**/*")
    .pipe(gulp.dest("D:\myphp_www\PHPTutorial\WWW\baidu\php"));
    });
    gulp.watch("img/**/*",async ()=>{
    gulp.src("img/**/*")
    .pipe(gulp.dest("D:\myphp_www\PHPTutorial\WWW\baidu\img"));

    });

    });

  • 相关阅读:
    nginx 服务企业应用
    3D模型展示以及体积、表面积计算
    php实现MySQL读写分离
    three.js实现3D模型展示
    thinkphp5.1+think-queue
    GIT记住远端仓库地址密码
    php实现采集(仅做参考)
    phpStudy集成环境apche+openssl配置本地https
    HTTP与HTTPS区别
    在父页面用Iframe加载子页面时,将父页面的title替换成子页面title
  • 原文地址:https://www.cnblogs.com/zwjun/p/11458507.html
Copyright © 2011-2022 走看看