gulp-livereload icon indicating copy to clipboard operation
gulp-livereload copied to clipboard

Livereload not working

Open mrmading opened this issue 7 years ago • 1 comments

For some reason livereload isn't working even I can see it succesfully injected in the html. Yesterday worked for a while but today it stopped without changing anything in the setup. I get also error of port already in use but even that yesterday it worked:

... Uhoh. Got error listen EADDRINUSE :::35729 ...
Error: listen EADDRINUSE :::35729"

Any idea of what could be happening? I am not running any other thing in that port for sure.

Here is my gulpfile:

var gulp = require('gulp'),
concat = require('gulp-concat'),
minifyCSS = require('gulp-minify-css');
sass = require('gulp-sass');
gls = require('gulp-live-server');
livereload = require('gulp-livereload');

gulp.task('sass', function(){
  gulp.src(['src/sass/**/*.scss'])
    .pipe(sass({includePaths: ['bower_components/foundation/scss']})) // Using gulp-sass
    .pipe(gulp.dest('src/css/'));

});


gulp.task('css',['sass'], function() {
    gulp.src([
        'src/css/**/*.css'
    ])
    //.pipe(minifyCSS())
    .pipe(concat('style.css'))
    .pipe(gulp.dest('public/css'))
    .pipe(livereload());
 });

 gulp.task('js', function() {
    gulp.src([
        'node_modules/jquery/jquery.js',
        'node_modules/bootstrap/js/bootstrap.js',
        'src/js/**/*.js'
    ])
    .pipe(concat('script.js'))
    .pipe(gulp.dest('public/js'));

 });

 gulp.task('images', function() {
    gulp.src([
        'src/images/**/*'
    ])
    .pipe(gulp.dest('public/images'));
 });

 gulp.task('livereload',function(){
  livereload({ start: true });
});

gulp.task('serve', function() {

  var server = gls.static('public', 8888);
  server.start();


 gulp.watch('src/css/**/*.css', function(event) {
    console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
    gulp.run('css');
 });

 gulp.watch('src/js/**/*.js', function(event) {
    console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
    gulp.run('js');
 });

 gulp.watch('src/images/**/*', function(event) {
    console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
    gulp.run('images');
 });
 gulp.watch('src/sass/**/*', function(event) {
    console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
    gulp.run('sass');
 });

});

gulp.task('default', ['sass','images','css', 'livereload','serve'] );

mrmading avatar Nov 02 '17 07:11 mrmading

The port you are using for livereload is used by something else. Change it.

zdenekhatak avatar Nov 13 '17 11:11 zdenekhatak