Gulp 将管道吸至单独的目标文件夹

Gulp 将管道吸至单独的目标文件夹,gulp,gulp-less,gulp-watch,Gulp,Gulp Less,Gulp Watch,我正在写一个吞咽任务,它通过几个文件夹查看更少的文件。我想通过管道将编译后的css返回到更少文件来自的同一文件夹。不幸的是,我似乎找不到一个好方法来为每个文件提供一个单独的输出文件夹 gulp.task('less:watch', function() { watch({ glob: 'src/**/less/**/*.less', emit: 'one', emitOnGlob: false },function(files){

我正在写一个吞咽任务,它通过几个文件夹查看更少的文件。我想通过管道将编译后的css返回到更少文件来自的同一文件夹。不幸的是,我似乎找不到一个好方法来为每个文件提供一个单独的输出文件夹

gulp.task('less:watch', function() {
    watch({
        glob: 'src/**/less/**/*.less',
        emit: 'one',
        emitOnGlob: false
    },function(files){
        return files
            .pipe(less({
                paths: [ path.join(__dirname, 'less', 'includes') ]
            }))
            // I need to pipe the files back to the folder they were generated from
            .pipe(gulp.dest(path.join(__dirname, 'less')))
            .on('error', gutil.log);
    });
});

我相信您可以通过
gulp.watch
一次处理一个文件:

gulp.task('less:watch', function() {
    gulp.watch('src/**/less/**/*.less',function(evnt) {
      return gulp.src(evnt.path)
        .pipe(less({
          paths: [ path.join(__dirname, 'less', 'includes') ]
        }))
        .pipe(gulp.dest(path.dirname(evnt.path)))
        .on('error', gutil.log);
    });
});