在我的gulpfile.js上,我有一些共同点.pipes()
的任务。现在我将它们复制/粘贴到我需要的地方,但理想情况下我想避免_ WET - 写两次所有内容。
一个例子:
gulp.task('scripts', function(){
console.log('start task scripts');
gulp.src([
folderScripts+'/**/*.js',
'!'+folderScripts+'/**/_*.js',
'!'+folderScripts+'/**/*.min.js'
])
// some .pipes() here
// --- FIXME Find a way to not duplicate this
.pipe(include())
.on('error', console.log)
.pipe(gulpif(argv.production, stripDebug()))
.pipe(rename({ suffix: '.min' }))
// --- END FIXME Find a way to not duplicate this
//more .pipes()
.pipe(gulp.dest('exported'));
logEnv();
});
gulp.task('min-this', function(){
// some code
if (argv.js || argv.jsfolder) {
gulp.src([
argv.js ? argv.js
: argv.jsfolder+'/**/*.js',
'!'+argv.jsfolder+'/**/_*.js',
'!'+argv.jsfolder+'/**/*.min.js'
])
// some .pipes() here
// --- FIXME Find a way to not duplicate this
.pipe(include())
.on('error', console.log)
.pipe(gulpif(argv.production, stripDebug()))
.pipe(rename({ suffix: '.min' }))
// --- END FIXME Find a way to not duplicate this
//more .pipes()
.pipe(gulp.dest( function(file) { return file.base; } ));
}
});
我怎么能不复制块// --- FIXME Find a way to not duplicate this
内的内容?
由于