Live reloading not working after Ctrl + S in GULP


#1

I do not know why those tasks for live reloading just disappear after the last Ionic Update I did. Now I am trying to fix this issue but still wondering why is not working. I am following this guide here and still can not see what is the error I have.

See some part of my gulpfile.js

    var paths = {
      sass: ['/scss/**/*.scss'],
      js: ['www/js/*.js', 'www/js/**/*.js', '!www/js/lib.min.js', '!www/js/code.min.js']
    };

    gulp.task('compress-lib', function() {
      gulp.src([
        './www/lib/ionic/js/ionic.bundle.min.js'
      ])
        .pipe(concat('lib.min.js'))
        .pipe(gulp.dest('./www/js'))
    });
    
    gulp.task('compress-js', function() {
      gulp.src([
        './www/js/app.js',
        './www/js/lines/controller.js',
        './www/js/lines/service.js'
      ])
        .pipe(ngAnnotate())
        .pipe(concat('code.min.js'))
        .pipe(gulp.dest('./www/js'))
    });
    
    // JSHint task
    gulp.task('lint', function() {
      gulp.src(paths.js)
          .pipe(jscs())
          .pipe(jshint())
          .pipe(jshint.reporter('default'));
    });
    
    gulp.task('sass', function(done) {
      gulp.src('./scss/ionic.app.scss')
        .pipe(sass({onError: function(e) { console.log(e); } }))
        .pipe(autoprefixer('last 2 versions', 'Chrome', 'ios_saf','Android'))
        .pipe(gulp.dest('./www/css/'))
        .pipe(minifyCss({
          keepSpecialComments: 0
        }))
        .pipe(rename({ extname: '.min.css' }))
        .pipe(gulp.dest('./www/css/'))
        .on('end', done);
    });
    
    gulp.task('watch', function() {
      gulp.watch(paths.sass, ['sass']);
      gulp.watch(paths.js, ['lint', 'compress-js']);
    });

every time I do ctrl + s on a file, in this case www/js/lines/controller.js, on the console you can see something like:

    [14:41:11] Starting 'lint'...
    [14:41:11] Finished 'lint' after 17 ms
    [14:41:11] Starting 'compress-js'...
    [14:41:11] Finished 'compress-js' after 5.31 ms
    JS changed:   www/js/lines/controller.js
    JS changed:   www/js/code.min.js

which means that there are some tasks working properly, but if I want to see those changes on the view, I have to go to the console and type gulp, do you have an idea why the app is not just reloading after ctrl + s ?


#2

I’m seeing the same issue with my watch task. Sometimes livereload works as expected, but sometimes it takes two saves to get the changes to appear. It seems to be a race condition between ionics livereload and the gulp watch task. Is there any way to get livereload to wait for the gulp tasks to finish?


#3

hm, this also drive me crazy also, I have been cost so much time about the solution, but still not found it. Any body can help?

the livereload only worked sometimes.