/**
* Welcome to your gulpfile!
* The gulp tasks are splitted in several files in the gulp directory
* because putting all here was really too long
*/
'use strict';
var gulp = require('gulp');
var wrench = require('wrench');
/**
* This will load all js or coffee files in the gulp directory
* in order to load all gulp tasks
*/
wrench.readdirSyncRecursive('./gulp').filter(function (file) {
return (/\.(js|coffee)$/i).test(file);
}).map(function (file) {
require('./gulp/' + file);
});
/**
* Default task clean temporaries directories and launch the
* main optimization build task
*/
gulp.task('default', ['clean'], function () {
gulp.start('build');
});
1条答案
按热度按时间mnemlml81#
这将加载gulp目录中的所有js或coffee文件,以便加载所有gulp任务,因此您不必手动导入新的gulp任务,只需在'/gulp'目录中创建whatevergulptask.js,您可以从命令行使用它。
这样做的另一个好处是,您没有一个包含数百万任务和代码行的巨大gulpfile.js,相反,每个任务都有一个whatevergulptask.js,这是一个很好的实践,因为gulpfile增长得非常快
gulpfile.js示例
您的文件夹结构