gulp-nodemon
gulp-nodemon copied to clipboard
browserSync.reload() not actually reloading browser
I have gulp-nodemon set up pretty much the same as the code sample and the browserSync.reload() does not reload the browser. After js or hbs file changes nodemon restarts node but browserSync is not reloading.
gulp.task('serve-server', function (callback) {
var called = false;
return nodemon({
// nodemon our expressjs server
script: 'bin/www',
env: { 'NODE_ENV': 'development' },
ext: 'js hbs',
// watch core server file(s) that require server restart on change
watch: ['/server/**/*.js', '/server/**/*.hbs'],
delay: 2000
})
.on('start', function onStart() {
// ensure start only got called once
if (!called) { callback(); }
called = true;
})
. on('restart', function onRestart() {
// reload connected browsers after a slight delay
setTimeout(function reload() {
browserSync.reload();
}, BROWSER_SYNC_RELOAD_DELAY);
});
});
gulp.task('serve-client', function() {
return browserSync.init({
port: 3005,
files: paths.clientFilesToWatch,
injectChanges: true,
logFileChanges: true,
logLevel: 'info',
notify: true,
reloadDebounce: 2000,
ghostMode: false,
proxy: {
target: 'http://localhost:3000',
ws: true
}
});
});
https://github.com/JacksonGariety/gulp-nodemon/issues/88 suggests to use start instead.