BrowserSync / gulp-browser-sync

How to use the Browsersync module with gulp.
http://browsersync.io
384 stars 27 forks source link

Files changes not detected on Windows 8 #17

Closed fsylum closed 10 years ago

fsylum commented 10 years ago

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.

shakyShane commented 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.

fsylum commented 10 years ago

You can take a look at full gulpfile here .

fsylum commented 10 years ago

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

shakyShane commented 10 years ago

Thanks for the info - I'll be looking into it

shakyShane commented 10 years ago

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] );
});
shakyShane commented 10 years ago

The 'once' option may not be around for long, so it would better to switch the above asap

shakyShane commented 10 years ago

Closing this, the above example should always be used now for one-time reloads