Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add synchronous method #28

Open
tamtakoe opened this issue Sep 11, 2015 · 2 comments
Open

Add synchronous method #28

tamtakoe opened this issue Sep 11, 2015 · 2 comments

Comments

@tamtakoe
Copy link

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)
}
@ashaffer
Copy link
Owner

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.

@maxkoryukov
Copy link
Contributor

@tamtakoe может не стоит этого делать? ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants