You cannot returncontents from a file in a gulp stream. This is not possible because the stream is asynchronous, so the content is not yet available when you try to execute returnit from your function.
You must listen to the "data"event in the stream, and then do everything you want to do in the event handler function:
gulp.task('build-html', function(cb) {
buildCSS().on('data', function(file) {
var cssText = file.contents.toString();
gulp.src(__dirname + '/src/template.html')
.pipe(g.replace('/*INJECT:CSS*/', cssText))
.pipe(gulp.dest(__dirname + '/dist/'))
.on('end', cb);
});
});
source
share