M
M
Maxim Semiletkin2019-12-15 15:21:03
JavaScript
Maxim Semiletkin, 2019-12-15 15:21:03

Why is Gulp taking so long to process a request?

What is the reason for such a long processing time?
5df6252730e03534510090.png

const gulp = require("gulp");
const rename = require("gulp-rename");
const autoprefixer = require("gulp-autoprefixer");
const sass = require("gulp-sass");
const sourcemaps = require('gulp-sourcemaps');
const browserSync = require('browser-sync').create();


//scss compile
function sassComp() {
    return gulp.src(`./scss/**/*.scss`)
        .pipe(sourcemaps.init())
        .pipe(sass({
            errorLogToConsole: true,
            outputStyle: 'compressed'
        }))
        .on("error", console.error.bind(console))
        .pipe(rename({suffix: '.min'}))
        .pipe(autoprefixer())
        .pipe(sourcemaps.write({
            errorLogToConsole: true,
        }))
        .on("error", console.error.bind(console))
        .pipe(gulp.dest("./css/"))
        .pipe(browserSync.stream());

}

// browser sync
function sync() {
    return browserSync.init({
        server: {
            baseDir: "./"
        },
        port: 3000
    })
}

// watch
function watchFiles() {
    gulp.watch("./scss/**/*.scss", sassComp);
    gulp.watch("./**/*.html").on('change', browserSync.reload);
    gulp.watch("./**/*.js").on('change', browserSync.reload);
    gulp.watch("./**/*.php").on('change', browserSync.reload);
}

gulp.task('default', gulp.parallel(sync, watchFiles));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2019-12-15
@edding8750

You need to separate development and production builds.
Building a project with all the minifications, generating source-maps and other stuff is a very hard process.
For local development, it is desirable to simplify this process. Remove compression, minification, prefixers, etc.
This will dramatically speed up development. Well, before deploying to the server - do a full build.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question