_
_
_umr2016-04-25 20:49:09
JavaScript
_umr, 2016-04-25 20:49:09

Why is my gulp with browserSync slow to process html files?

js files didn’t go anywhere, the stylus is instant (perhaps because there are few styles), but html has to wait as long as 3 seconds

var gulp        = require('gulp'),
    stylus      = require('gulp-stylus'),
    minify      = require('gulp-minify-css'),
    rename      = require('gulp-rename'),
    browserSync = require('browser-sync'),
    nib         = require('nib'),
    concat      = require('gulp-concat'),
    changed     = require('gulp-changed'),
    plumber     = require('gulp-plumber'),
    uglify      = require('gulp-uglify'),

    sourcemaps  = require('gulp-sourcemaps');

sourcemaps.init();

gulp.task('browserSync', function() {
    browserSync();
})


gulp.task('stylus', function() {
    gulp.src('app/stylus/*.styl')
        .pipe(plumber())
        .pipe(changed('app', { extension: '.styl' }))
        .pipe(stylus({ use: nib() }))
        .pipe(minify())
        .pipe(rename('main.min.css'))
        .pipe(gulp.dest('app/build/'))
        .pipe(browserSync.reload({ stream: true }));
});

gulp.task('js', function() {
    gulp.src('app/js/*.js')
        .pipe(plumber())
        .pipe(changed('app', { extension: '.js' }))
        .pipe(concat('vendor.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('app/build/'))
        .pipe(browserSync.reload({ stream: true }));
});

gulp.task('html', function() {
    gulp.src('*.html')
        .pipe(plumber())
        .pipe(changed('/', { extension: '.html'}))
        .pipe(browserSync.reload({ stream: true }));
});

// Rerun the task when a file changes
gulp.task('watch', function() {
    gulp.watch('*.html', ['html']);
    gulp.watch('app/js/*.js', ['js']);
    gulp.watch('app/stylus/*.styl', ['stylus']);
});

// The default task (called when you run `gulp` from cli)
gulp.task('default', ['browserSync', 'stylus', 'js', 'html', 'watch']);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timofey Dergachev, 2016-04-25
@Umr001

Perhaps he is looking for them in node_modules as well. Try moving the html to a separate directory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question