【问题标题】:How to convert gulp watch script into gulp 4如何将 gulp watch 脚本转换为 gulp 4
【发布时间】:2020-05-29 23:52:18
【问题描述】:

我最近已将我的节点版本升级到 v12,并且我有一个在 gulp 3.8 上运行的 angular 项目,通过遵循一些建议,我已将我的 gulp 版本升级到 4.0,并使用 gulp.series 和并行修改了一些脚本。但我在下面的脚本中遇到了问题。任何人都可以帮助我将以下监视文件转换为 gulp 4.0 脚本。


var gulp = require('gulp');

var paths = gulp.paths;

gulp.task('watch', ['inject'], function () {
  gulp.watch([
    paths.src + '/*.html',
    paths.src + '/{app,components}/**/*.less',
    paths.src + '/{app,components}/**/*.js',
    'bower.json'
  ], ['inject']);
});

【问题讨论】:

    标签: node.js angularjs gulp


    【解决方案1】:
    gulp.task('watch', gulp.series('inject', function () {
      gulp.watch([
        paths.src + '/*.html',
        paths.src + '/{app,components}/**/*.less',
        paths.src + '/{app,components}/**/*.js',
        'bower.json'
    
       ], 'inject');  // this should work as well since you have only one task to run
      //   however in the future you may want to add another task as in the below.
      // ], gulp.series('inject', 'anotherTask`));
    
    
    
    }));
    

    在 v4 中任务不在数组中,而是在 gulp.seriesgulp.parallel 中。

    【讨论】:

      猜你喜欢
      • 2019-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-18
      • 1970-01-01
      • 1970-01-01
      • 2020-05-24
      相关资源
      最近更新 更多