我想知道是否有任何方法可以将这两个单独的任务合并为一个。
此concat-js
任务需要在运行之前存在生成的文件。该任务cache-angular-templates
生成该文件。生成的文件需要包含在concat
输出中。完成后concat-js
,可以删除该文件——不再需要它。
似乎我应该能够以某种方式将流中使用的cache-angular-tempaltes
流导入流concat-js
使用中。
gulp.task('concat-js', ['cache-angular-templates'], function () {
var concatOutputPath = path.dirname(paths.compiledScriptsFile),
concatOutputFileName = path.basename(paths.compiledScriptsFile),
jsFiles = [].concat(
paths.libScripts,
paths.appScripts,
paths.templateScriptFile,
notpath(paths.compiledScriptsFile),
notpath(paths.specMockScripts),
notpath(paths.specScripts)
);
return gulp
.src(jsFiles)
.pipe(buildTools.concat(concatOutputFileName))
.pipe(gulp.dest(concatOutputPath))
.on('end', function () {
del(paths.templateScriptFile);
})
;
});
gulp.task('cache-angular-templates', function () {
var cacheOutputPath = path.dirname(paths.templateScriptFile),
cacheOutputFileName = path.basename(paths.templateScriptFile);
var options = {
root: '/' + cacheOutputPath,
standalone: true,
filename: cacheOutputFileName
};
return gulp
.src(paths.templates)
.pipe(buildTools.angularTemplatecache(options))
.pipe(gulp.dest(cacheOutputPath))
;
});