node package manager
Easy sharing. Manage teams and permissions with one click. Create a free org »

html-inject-css

html-inject-css

Transform stream for injecting css tags into html.

example:

var injectCss = require('html-inject-css')
 
process.stdin
.pipe( injectCss(['./main.css', './extra.css']) )
.pipe( process.stdout )

input:

<html><head></head><body>hello</body></html>

output:

<html><head><link href="./main.css" rel=stylesheet><link href="./extra.css" rel=stylesheet></head><body>hello</body></html>

cli

cat index.html | htmlinjectcss "main.css" > output.html

Gotcha:

requires a head tag to be present in the src.