【问题标题】:Excluding subdirectory from gulp-watch throwing type error从 gulp-watch 抛出类型错误中排除子目录
【发布时间】:2015-08-15 08:08:20
【问题描述】:

我正在运行以下监视任务:

gulp.task('watch', function() {

    gulp.watch('./ui/scss/*.scss', ['styles']);
    gulp.watch('./js/*.js', '!./js/vendor/*.js', ['scripts']);
    gulp.watch('./**/*.html', ['html']);

});

但是好像抛出如下错误?...

TypeError: Cannot assign to read only property 'mark' of !./js/vendor/*.js at new Gaze

【问题讨论】:

    标签: gulp gulp-watch


    【解决方案1】:

    如果要指定多个路径,则需要在路径周围加上括号。为您的第二块手表尝试以下方法:

    gulp.watch(['./js/*.js', '!./js/vendor/*.js'], ['scripts']);
    

    gulp.watch 处理文件参数的方式与vinyl-fs 相同。因此,您也可以使用他们在gulp.watch 中的文档中指定的所有功能。

    【讨论】:

      【解决方案2】:

      手表的第二个参数必须声明为数组

      gulp.watch('src...', ['taskname', ......];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-11-19
        • 2014-06-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多