我正在寻找一种方法来让gulp监视目录的json

时间:2019-02-18 12:28:48

标签: gulp gulp-watch

var paths = {
    css: "css/**/*.{scss,sass}",
    js: "js/**/*.js",
    other: ["fonts/**/*.ttf", "images/**/*.{gif,png,jpg}", "includes/**"]
}

我可以跑步

gulp.watch(paths.css, css); //compile sass and copy to template directory
gulp.watch(paths.js, js); //compile js and copy to template directory
gulp.watch(paths.other, copy_other); //when something changes in these, copy to template output directory

但是,这不会从模板输出目录中删除已删除的文件。当我删除时说js / test.js时,它只是编译所有js并将它们复制到输出中,但没有从模板输出目录中删除test.js。 我想要一个额外的监视线程,以在给定路径json对象的每个路径中查找已删除的文件

gulp.watch(paths).on("unlink", function(path) {
        delete(path);
     }); //delete() takes filename and deletes it in template output directory

不起作用,因为watch需要一个字符串而不是json对象:

TypeError: expected a string

仅使用cwd()+“ / **”就抱怨文件太多。

Error: ENOSPC: System limit for number of file watchers reached...

0 个答案:

没有答案