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"));

    });

    });

  • 相关阅读:
    附件下载遇到 ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION 错误
    Javascript模块编程&jQuery插件开发学习笔记
    网站推荐
    分布式服务下Quartz任务变为EREOR分析及解决
    Quartz任务监听器
    定时任务框架Quartz基本使用
    2020年CKA考试分享
    vue-element-loading 动态插件
    pycharm之常用插件
    PHP开源项目之YOURLS
  • 原文地址:https://www.cnblogs.com/zwjun/p/11458507.html
Copyright © 2011-2022 走看看