H
H
howehohit2015-11-03 13:22:16
css
howehohit, 2015-11-03 13:22:16

How to overcome and run livereload in browsersync?

Hello. I have been struggling with this problem for several days now - categorically does not want to work reloading the page with gulp in the browserSync plugin. The server starts, the local version and the tunnel are working. But not an overload. I installed the connect and livereload plugins separately - everything works there, but there is no tunnel creation function in the connection, and this is quite critical.
One way to connect (now):

var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;

gulp.task('web', function () {
    browserSync.init({
        server: {
            baseDir: "./build/"
        }
    });

    gulp.watch('src/css/style.css').on("change", browserSync.reload);
});

Moreover, a message is displayed in the console about reloading the c2n.me/3pLYx5u browser , but in fact there is no reload in any browser :(
PS I don’t know what to do anymore. I made a new project, here is all the code that is in it:
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var reload      = browserSync.reload;

gulp.task('web', function () {
    browserSync.init({
    server: {
      baseDir: "./build"
    }
  });
  
  gulp.watch('src/css/', browserSync.reload);
});

gulp.task('css', function() {
  gulp.src('src/css/style.css')
  .pipe(gulp.dest('build/css/'));
});

gulp.task('watch', ['css'], function(){
  gulp.watch('src/css/style.css', ['css']);
});

gulp.task('default', ['web', 'css', 'watch']);

And it still doesn't work!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2015-11-03
@streetflush

gulp.task('browser-sync', function() {
    browserSync.init({
        server: {
            baseDir: "./client"
        }
    });

    gulp.watch("./client/**/*.html", browserSync.reload);
    gulp.watch("./client/**/*.js", browserSync.reload);
});

This is how it all works for me. Don't forget './src/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question