我正在尝试执行以下操作。从可能是 JS 或 COFFEE 的文件数组中,编译咖啡,丑化特定文件,然后将它们全部连接起来。我不明白为什么我的过滤器无法解决 uglify。它似乎与咖啡一起使用,但使用 uglify 过滤器似乎并没有看到它,只是对所有文件进行了 uglify。
var gulp = require('gulp');
var coffee = require('gulp-coffee');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var src = [
'app/assets/1.js',
'app/assets/2.js',
'app/assets/components/1.coffee',
'app/assets/components/2.js',
'app/assets/utilities/*'
];
var coffeeSrcFilter = $.filter(['*.coffee']);
var minifyExclusionSrcFilter = $.filter(['*', '!app/assets/components/2.js']);
return gulp.src(paths.scripts)
.pipe(sourcemaps.init())
// coffee
.pipe(coffeeSrcFilter)
.pipe(coffee())
.pipe(coffeeSrcFilter.restore())
// uglify
.pipe(minifyExclusionSrcFilter)
.pipe(uglify())
.pipe(minifyExclusionSrcFilter.restore())
// concat
.pipe(gulpConcat('out.js'))
.pipe(gulp.dest('build/js'));
});