Closed fsylum closed 10 years ago
Can I see your browser sync task also please :)
Sent from my iPhone
On 15 Jun 2014, at 08:40, Firdaus Zahari notifications@github.com wrote:
Hi,
I'm not entirely sure if this is restricted only to my env, but I'm compiling my html using gulp-assemble (in beta), but when settings once to true, it seems like only the first time file changes is being trigger by default gulp.watch. Removing the once value, the gulp.watch tasks triggered perfectly when file changes, but as the parameter suggest, it causes browser to multiple reload.
Here's my `html task
gulp.task( 'html', function() { return gulp.src( paths.html.pages ) .pipe( $.assemble( paths.html.options ) ) .pipe( $.htmlhint({ htmlhintrc: '.htmlhintrc' }) ) .pipe( $.htmlhint.reporter() ) .pipe( $.cleanhtml() ) .pipe( $.prettify({ config: '.jsbeautifyrc' }) ) .pipe( gulp.dest( paths.html.dest ) ) .pipe( browserSync.reload({ stream: true, once: true }) ); }); and my watch task
gulp.task( 'watch', ['browser-sync'], function() { gulp.watch( paths.html.src, ['html'] ); }); Can you replicate this issue in your Windows machine as well? Using browser-sync 0.9.1.
Thanks.
— Reply to this email directly or view it on GitHub.
Additional, can confirm it's related to browsersync reload statement. Somewhat similar thread on SO: http://stackoverflow.com/questions/21389243/gulp-watch-running-only-once-on-windows
Basically once the browser-sync.reload() is commented out, gulp.watch managed to detect subsequent file changes
Thanks for the info - I'll be looking into it
This is a better approach when all you want is a reload following a task.
gulp.task( 'html', function() {
return gulp.src( paths.html.pages )
.pipe( $.assemble( paths.html.options ) )
.pipe( $.htmlhint({ htmlhintrc: '.htmlhintrc' }) )
.pipe( $.htmlhint.reporter() )
.pipe( $.cleanhtml() )
.pipe( $.prettify({ config: '.jsbeautifyrc' }) )
.pipe( gulp.dest( paths.html.dest ) );
});
gulp.task( 'watch', ['browser-sync'], function() {
gulp.watch( paths.html.src, ['html', browserSync.reload] );
});
The 'once' option may not be around for long, so it would better to switch the above asap
Closing this, the above example should always be used now for one-time reloads
Hi,
I'm not entirely sure if this is restricted only to my env, but I'm compiling my html using gulp-assemble (in beta), but when settings
once
totrue
, it seems like only the first time file changes is being trigger by defaultgulp.watch
. Removing theonce
value, thegulp.watch
tasks triggered perfectly when file changes, but as the parameter suggest, it causes browser to multiple reload.Here's my `html task
and my
watch
taskCan you replicate this issue in your Windows machine as well? Using browser-sync 0.9.1.
Thanks.