Answer the question
In order to leave comments, you need to log in
Why are there problems with livereload and gulp when there are a lot of html templates?
When the project grows, there are problems with compiling jade and liveroaload does not refresh the page on the first time in the browser.
I'm not quite sure what the problem could be and what it is connected with.
Has anyone else experienced something similar and knows how to fix it?
My gulpfile.js looks like this.
// Modules
var gulp = require('gulp'),
connect = require('gulp-connect'),
jade = require('gulp-jade'),
stylus = require('gulp-stylus'),
autoprefixer = require('gulp-autoprefixer'),
plumber = require('gulp-plumber');
// Local server
gulp.task('connect', function () {
connect.server({
root: ['build'],
livereload: true
});
});
// Stylus
gulp.task('stylus', function () {
gulp.src('stylus/main.styl')
.pipe(plumber())
.pipe(stylus({compress: false}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('build/styles'))
.pipe(connect.reload());
});
// Jade
gulp.task('jade', function() {
gulp.src(['jade/*.jade', '!jade/includes/*.jade'])
.pipe(plumber())
.pipe(jade({pretty: true}))
.pipe(gulp.dest('build'))
.pipe(connect.reload());
});
// Javascripts
gulp.task('javascripts', function () {
gulp.src('javascripts/**/*.js')
.pipe(plumber())
.pipe(gulp.dest('build/javascripts'))
.pipe(connect.reload());
});
// Images
gulp.task('images', function () {
gulp.src('images/**/*')
.pipe(gulp.dest('build/images'))
});
// Watching
gulp.watch(['stylus/*.styl'], ['stylus']);
gulp.watch(['jade/*.jade'], ['jade']);
gulp.watch(['javascripts/*.js'], ['javascripts']);
gulp.watch(['images/**/*'], ['images']);
// Run
gulp.task('default', ['connect', 'images', 'jade', 'stylus', 'javascripts']);
Answer the question
In order to leave comments, you need to log in
Livereload is not the best solution. Browsersync works better and faster .
In general, I advise you not to bathe and use TARS , everything is there out of the box and even more.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question