_
_
_umr2016-06-19 13:44:13
gulp.js
_umr, 2016-06-19 13:44:13

Gulp processes js script for a very long time, what to do?

My gallp processes any change in the script in 5-10 seconds. There are 10 more scripts in the js folder that do not change. There are few lines in my script.

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(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(concat('vendor.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('app/build/'))
        .pipe(browserSync.reload({ stream: true }));
});

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

// Rerun the task when a file changes
gulp.task('watch', function() {
    gulp.watch('app/html/*.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)
A
Artem Kayun, 2016-06-19
@Umr001

Create 2 js tasks. One for development, without iglyify, and the other for production, the one you have now. Why do you need to compress js during development.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question