Gulp Livereload not working with multiple .html files



gulpfile.js (2.1 KB)

var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var sourceMaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var autoprefixer = require('gulp-autoprefixer');
var connect = require('gulp-connect');
var wait = require('gulp-wait');

var sassConfig = {
    errLogToConsole: true,
    outputStyle: 'expanded',

gulp.task('hello', function() {
    console.log('Hello World!');

gulp.task('copyfiles', function () {
    gulp.src(['./*.html', './css/*.css', './assets/***/**/*', 'js/**/*.js'], { base: './' })

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

gulp.task('webserver', function () {
        port: 3000,
        host: 'localhost',
        livereload: true

gulp.task('sass', function() {
    return gulp
        .pipe(sass(sassConfig).on('error', sass.logError))

// gulp.task('reload', function () {
//     gulp.src(['index.html', 'about.html', 'results.html', 'js/main.js', 'scss/**/*.scss', 'css/*.css'])
//         .pipe(connect.reload())
// });

gulp.task('reload', function () {
    gulp.src(['./*.html' ,'js/main.js', 'scss/**/*.scss', 'css/*.css'])

gulp.task('watch', function () {'scss/**/*.scss', ['sass']);['index.html', 'js/main.js', 'scss/**/*.scss', 'css/main.css', 'about.html', 'results.html'], ['reload']);

gulp.task('uglify', function() {
    return gulp
        .src(['js/main.js', 'js/plugins.js'])

gulp.task('default', ['webserver', 'watch', 'sass']);
// gulp.task('default', ['webserver', 'watch']);

The problem is that I have multiple .html files but gulp reloads the browser only if it's the index.html file. I have a about.html and a results.html file but the browser doesn't update the page for the about page nor the results page. But in this case the terminal shows that the task is running even if I make change to the other .html files. There's a problem with either the reload task or the webserver task probably. What should I do?


I see from the gulp-livereload page that it will not automatically listen for changes. Instead, they give some info on manually calling it, or setting the start option.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.