Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gulp-live-server doesn't refresh page

I'm trying to use gulp-live-server to automatically restart my server and refresh the page whenever my code changes.

Here is the basic setup I have:

On my server.js:

app.use(require('connect-livereload')());

My gulp file:

gulp.task('server', function () {
   server = gls('app.js', options);
    server.start();

    // Watch for file changes
    gulp.watch(['app.js', 'app/**/*.js', 'config/**/*.js', 'components/**/*.jsx'], function() {
        server.start.bind(server)();
        server.notify.bind(server)();
    });
});

My server successfully does restart, but the browser does not refresh ever.

Help is appreciated.

like image 207
Kousha Avatar asked Feb 22 '26 18:02

Kousha


1 Answers

Try by passing the file when calling notify:

gulp.task('server', function () {
   server = gls('app.js', options);
    server.start();

    // Watch for file changes
    gulp.watch(['app.js', 'app/**/*.js', 'config/**/*.js', 'components/**/*.jsx'], function(file) {
        server.start.bind(server)();
        server.notify.bind(server)(file);
    });
});
like image 123
Maluen Avatar answered Feb 24 '26 09:02

Maluen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!