gulp-community / gulp-livereload

gulp plugin for livereload
768 stars 67 forks source link

Doesn't reload a browser #63

Closed wzup closed 9 years ago

wzup commented 9 years ago

Here is my gulpfile.js:

var gulp = require('gulp'),
    gutil = require('gulp-util'),
    browserify = require('gulp-browserify'),
    nodemon = require('gulp-nodemon')
    compass = require('gulp-compass'),
    gulpif = require('gulp-if'),
    uglify = require('gulp-uglify'),
    // minifyHTML = require('gulp-minify-html'),
    concat = require('gulp-concat'),
    livereload = require('gulp-livereload'),
    path = require('path');

var port,
    env,
    nodemonConf,
    scssSources,
    scssStyle,
    jsSources,
    templateSources,
    outputDir;

port = 3000;
env = 'development';

nodemonConf = {
    script: "index.js",
    ext: 'js html dust json scss',
    env: { 'NODE_ENV': env },
    nodeArgs: ['--debug']
}

if (env==='development') {
    scssStyle = 'expanded';
} else {
    scssStyle = 'compressed';
}

gulp.task("livereload", function() {
    livereload.listen();
});

gulp.task('dev', function() {
    nodemon(nodemonConf)
        .on('restart', function () {
            livereload();
            console.log('== Restarted! ==');
        });
});

gulp.task('default', ["livereload", "dev"]);

Doesn't reload a browser. Why? How to enable?

mastilver commented 9 years ago

Hi

Did you try by replacing livereload() by livereload.changed('*') ?

cyrusdavid commented 9 years ago

livereload() simply creates a stream, it does not reload things. Use it with a readable stream or call livereload.reload() or livereload.changed(path) to invoke a reload.

cyrusdavid commented 9 years ago

Also, see the nodemon example :sparkles: :sparkles: