1

我正在使用 gulp-coffee 将我的咖啡文件编译为 js,没什么特别的。

我很难弄清楚如何删除源文件夹js中不再存在的 js 文件(在 dest 目录中) 。coffee

我很确定这与 gulp-coffee 没有直接关系,但我有点无能为力,而且我对 gulp 也不是很精通。

我的文件结构

/app/
  /coffee (source)
  /js     (dest)

我的吞咽任务

gulp.task('coffee', function() {
    return gulp.src('app/coffee/**/*.coffee')
    .pipe($.changed('./app/js/', {extension: '.js'}))
    .pipe($.coffee())
        .on('error', logCoffeeError)
    .pipe(gulp.dest('app/js/'));
});
4

1 回答 1

1

如果有人对这个问题的解决方案感兴趣,我最终会使用这个包,它完全符合我的要求:https ://github.com/StevenTheEVILZ/gulp-syncronize

用法:

gulp.task('unused', function() {
    return syncronize({
        src:    'app/coffee/',  //Source folder
        target: 'app/js/',      //Output folder
        extensions: {
            'js': 'coffee', // Corresponds .js files to the .coffee files; 
        }
    });
});
于 2016-06-14T09:18:31.090 回答