G
G
gassmonkey2015-07-24 10:57:16
css
gassmonkey, 2015-07-24 10:57:16

Which gulp plugin can only embed inline styles from a specific file into a page?

Which gulp plugin can only embed inline styles from a specific file into an html page?
A few that have been tried embed all the styles included on the page.
Ideally, you need a plugin with a minimum of settings that takes the specified css file and embeds its styles into the header of the specified page.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2015-07-24
Protko @Fesor

gulp injection

F
fantazerno, 2015-08-21
@fantazerno

replace = require('gulp-replace')

var fs = require('fs');
var pls = '<link rel="stylesheet" href="wp-content/themes/dist/css/vendor.css">';
gulp.task('csspush', function(){
 return gulp.src('wp-content/themes/dist/header.php')
  .pipe(replace(pls,function(s) {
      var style = fs.readFileSync('./wp-content/themes/dist/css/vendor.css', 'utf8');
      return '<style>\n' + style + '\n</style>';
  }))
  .pipe(gulp.dest('wp-content/themes/dist/'));
});

on the example of WP

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question