gulp-inline-css icon indicating copy to clipboard operation
gulp-inline-css copied to clipboard

Use files from stream instead of parsing the document

Open thasmo opened this issue 10 years ago • 0 comments
trafficstars

I'd love to use something like this:

gulp.src(['index.html', 'styles/*.css'])
    .pipe(if('*.html', inlineCss({
        parse: false,
        stream: '*.css'
    })))

Which would just use all CSS files from the stream and it would not parse the template.

Currently I'm trying something like this which of course doesn't work:

gulp.task('templates', function() {
    var assets = useref.assets();

    return gulp.src('source/template/*.jade')
        .pipe(jade()) // Compile the templates to HTML
        .pipe(assets) // Find referenced stylesheets
        .pipe(assets.restore()) // Restore HTML file
        .pipe(if('*.scss', sass())) // Compile SASS to CSS
        .pipe(if('*.html', inlineCss())) // Inline stylesheets
        .pipe(gulp.dest('public/')); // Write HTML files to destination
});

Basically I want to get referenced SASS files from within the templates, compile them to CSS and apply them to the template using gulp-inline-css without creating temporary files.

Is there any way to do this right now? Would be nice to have this feature and use it as easy as possible!

thasmo avatar Mar 18 '15 22:03 thasmo