gulp-inline
gulp-inline copied to clipboard
Add synchronous method
var inline = require('gulp-inline')
var processedContent = inline.sync(content, baseUrl, options);
//or
var processedVinylFile = inline.sync(vinylFile, options);
It is useful for some situation. F.e. if I processindex.html I don't need to create a stream for a single file
function buildProject(options) {
function transform(file, enc, callback) {
//Transform each .js/.css/.html file
}
function flush(callback) {
//It is more comfortable then use gulp.src(indexPath).pipe(inline()).pipe(someCompileFn())
var indexContent = fs.readFileSync(path.join(options.baseUrl, 'index.html'));
var compiledIndex = new gutil.File({
path: newIndexPath,
contents: new Buffer(inline.sync(indexContent , options.baseUrl), 'utf8');
})
this.push(compiledIndex);
}
return through.obj(transform, flush)
}
Hmm...I think probably I ought to break out an inline module that synchronously inlines an individual file, which gulp-inline may then consume. I'll have to think about this a bit.
@tamtakoe может не стоит этого делать? ;)