metalsmith-browser-sync
metalsmith-browser-sync copied to clipboard
How to inject CSS without reload? What am I doing wrong?
Here's my metalsmith pipeline:
metalsmith(__dirname)
.use(markdown())
.use(prism())
.use(metadata())
.use(permalinks())
.use(inplace())
.use(layouts())
.use(assets())
.use(sass())
.use(prefix())
.use(uglify())
.use(browsersync(files: [
"layouts/**/*",
"pages/**/*",
"assets/**/*"
]))
.build();
Any ideas? Do I need to be running browsersync in a separate pipeline branch or something?
Also, I'm not getting any file change logs, just the reload:

Hey @mdvorscak, did you perhaps get a chance to consider this question yet? I'm stuck :/
Does your index.html file have a <body> tag? https://browsersync.io/docs/#requirements
@mhkeller thanks for suggestion! I do have body tags in my index, and I also tried moving around some of my handlebars templates to double check and am pretty sure that's not the issue. I'm getting a the full reload, which if I recall from other projects, would break without the
tag.
Hi @jamiewilson did you fix your issue ? I'm having exactly the same problem. Thank you
I just quickly added this to index.js line 27 to fix
function rebuild(event, file) {
if (!bs.paused) {
bs.pause();
metalsmith.build(function(err) {
var buildMessage = err ? err : 'Build successful';
debug(buildMessage);
bs.resume();
if (require('path').extname(file) === '.scss') {
bs.reload('*.css');
} else {
bs.reload();
}
});
}
}