【发布时间】:2015-05-31 09:16:36
【问题描述】:
我想取一个CSS处理步骤getCss和一个JS处理步骤getJs的结果,然后用这两个结果创建一个名为index.html的文件,这是内联处理后的结果将 CSS 和 JS 处理成一个名为 index-template.html 的模板。
有人可以帮助我更好地了解如何实现这一目标吗?
这就是我目前所拥有的......
gulp.task('build', function() {
eventStream.merge(getCss.bind(gulp), getJs.bind(gulp))
.pipe(inlineJsAndCss.bind(gulp));
});
function getCss() {
return this.src(options.lessGlob)
.pipe(less())
.pipe(minifyCss());
}
function getJs() {
return this.src(options.jsGlob)
.pipe(uglify());
}
function inlineJsAndCss() {
// Take the CSS and the JS generated by
// previous steps and inline them into
// index-template.html
//...
.pipe(this.dest('index.html'));
}
编辑:将中间步骤的结果存储在内存中,然后从中创建一个流,这是实现此目的的规范方法吗?
https://github.com/gulpjs/gulp/blob/master/docs/recipes/make-stream-from-buffer.md
【问题讨论】:
标签: javascript stream gulp