I need to inject css in html. The project structure is as follows:
/
html/
my-app.html
app-header.html
...
css/
my-app.css
app-header.css
...
So, each of the html files contains:
<style>
<!-- inject:css -->
</style>
And I want to inject the css into the html. So I found the following gulp task:
gulp.task('replace', function() {
gulp.src('html/*.html')
.pipe(replace(/<!-- inject:css -->/, function(s) {
var style = fs.readFileSync('style.css', 'utf8');
return style;
}))
.pipe(gulp.dest('./dist/tmp'));
});
As you can see, the input css filename is incorrect and should match the name of the html file (but html replaced with css of course!)
How can I access the filename inside that function? or is there a better way to get this job done ?