【发布时间】:2015-02-01 04:13:37
【问题描述】:
我想知道是否有任何方法可以将这两个独立的任务合二为一。
此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))
;
});
【问题讨论】:
标签: angularjs gulp gulp-concat