I need to insert the content of a stylesheet into the <head>
of an HTML page. How can I do it in Gulp?
Before (what I have):
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
After (what I want):
<head>
<style>
p { color: pink; }
</style>
</head>
Note that I do not need to inline CSS into the elements, but just put the contents of CSS in the <head>
.
You can inline the styles using import:
You could easily use
gulp-replace
, like so:You can also easily modify the replacement RegEx to work with different files, too.