Umr001
@Umr001
php

Почему мой gulp c browserSync медленно обрабатывают html файлы?

js файлы куда не шло, стайлус мгновенно (возможно потому-что мало стилей), а вот html приходиться ждать аж секунды 3

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']);
  • Вопрос задан
  • 418 просмотров
Решения вопроса 1
exeto
@exeto
front-end developer
Возможно он ищет их и в node_modules. Попробуйте вынести html в отдельную директорию.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы