Open basham opened 9 years ago
From http://stackoverflow.com/a/23834812
var gulp = require('gulp'),
replace = require('gulp-replace'),
fs = require('fs');
// in your task
return gulp.src(...)
.pipe(replace(/<link href="style.css"[^>]*>/, function(s) {
var style = fs.readFileSync('style.css', 'utf8');
return '<style>\n' + style + '\n</style>';
}))
.pipe(gulp.dest(...));
return gulp.src(...)
.pipe(replace(/<link href="([^\.]+\.css)"[^>]*>/g, function(s, filename) {
var style = fs.readFileSync(filename, 'utf8');
return '<style>\n' + style + '\n</style>';
}))
.pipe(gulp.dest(...));
Try to make reports as independent as possible by ensuring there's no external dependencies, such as CSS. Use gulp-replace or gulp-inline-source.