2016-10-23 2 views
0

하나의 파일을 꿀꺽 거리는 작업에 전달하는 방법이 궁금합니다.
전체 파일 컬렉션을 필터링하고 싶지 않고 작업별로 컬렉션의 모든 파일을 구문 분석하는 데 리소스를 낭비하고 싶지 않습니다.
그래서 가장 좋은 방법은 gulp.watch()에서 하나의 변경된 파일을 꿀꺽 거리는 작업에 전달하는 것이지만 작동하는 해결책이 없다고 생각했습니다.
watcher에서 매개 변수가있는 꿀꺽 거리는 작업을 실행하십시오.

gulp.task('html', function(file) { 
    return gulp.src(file) 
     .pipe(fileInclude(fileIncludeConf)) 
     .pipe(gulp.dest(paths.dest.templates)); 
}); 

gulp.task('watch', function() { 
    gulp.watch(path.src.templates).on('change', function(file) { 
     // gulp run 'html' task with 'file' as src 
    }) 
}); 

같은 꿀꺽 작업을 실행하는 방법이 있나요? 나는 task 대신 function으로 시도했지만 작동하지 않는다.

답변

0

gulp-cached 또는 gulp-changed과 같이 변경된 파일 만 전달하려는 것 같습니다. 따라서 :

var cache = require('gulp-cached'); 

gulp.task('html', function(file) { 
    return gulp.src(file) 
     .pipe(cache("only working on changed files here") 
     .pipe(fileInclude(fileIncludeConf)) 
     .pipe(gulp.dest(paths.dest.templates)); 
}); 

gulp.task('watch', function() { 
    gulp.watch(path.src.templates, ['html']) 
}); 
관련 문제