4

I'm experiencing long (~30s) rebuilds of several of my gulp tasks. I'm first transpiling using babel, then uglifying and finally concatenating the respective files.

I determined that most of the time is spent on uglifying -- so I'm skipping the already minified (+uglified) files too but to little avail. Then I tried injecting gulp-cached and gulp-changed-in-place before and after (not at once) the uglify() call without significant improvement. Even worse, they mis-compiled my files and apparently even skipped some of them which rendered my final JS useless.

With regards to changed-in-place -- by the time the previous uglified file's hash can be compared to the new one, I've already killed time by uglifying in the first place...

I'm wondering how I can efficiently skip unchanged files and their corresponding gulp tasks.

Here's the relevant part of my gulpfile:

myTasks.forEach(function (taskName) {
    gulp.task(taskName, function () {
        return gulp.src(tasks[taskName])
            .pipe(
                gulpBabel({
                    presets: ['es2015', {
                        'ignore': [
                            '**/*.min.js'
                        ]
                    }],
                    plugins: ['transform-object-rest-spread']
                }).on("error", function (e) {
                    console.error({
                        babelError: e
                    });
                })
            )
            .pipe(
                is_prod()
                    ? uglify().on("error", function (e) {
                        console.warn(e);
                    })
                    : noop_()
            )
            .pipe(concat(taskName + '.min.js'))
            .pipe(gulp.dest('my-dist-folder'));
    });
});
Joe - GMapsBook.com
  • 15,787
  • 4
  • 23
  • 68

0 Answers0