Skip to content

Add synchronous method #28

@tamtakoe

Description

@tamtakoe
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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions