Skip to content

The new syntax for running tasks is slower? #225

Description

@lmartins

For some reason, after changing my gulp file to the new format (removing gulp.run) the compilation time for gulp-sass became noticeable slower.

What usually took:

gulp] Finished 'sass' in 870 μs

Not takes:

[gulp] Finished 'sass' in 269 ms

It's not a huge difference I know, but still, worth nothing I guess.

Activity

  1. robrich commented on Jan 31, 2014

    @robrich
    Contributor

    Can you post your gulpfile.js before and after please?

  2. lmartins commented on Feb 1, 2014

    @lmartins
    Author

    I've managed to isolate the part of the gulp file that affects compilation times.

    It's actually the returnbefore gulp.src in my sass task. I've added that return as I've saw it mentioned in a few recipes. Since the compilation works faster without it im removing it.

    Im also closing the ticket as this is most likely a configuration problem. If that isn't the case, please let me know.

    // Include gulp
    var gulp = require('gulp'),
        lr = require('tiny-lr'),
        sass = require('gulp-sass'),
        prefix = require('gulp-autoprefixer'),
        plumber = require('gulp-plumber'),
        livereload = require('gulp-livereload'),
        server = lr(),
        notify = require("gulp-notify");
    
    var options = {
        SASS_SOURCE : "sass/**/*.scss",
        CSS_DEST : "../assets/css/",
        // JavaScript
        JS_SOURCE : "src/scripts/**/*.js",
        JS_DEST : "dist/assets/js",
        JS_CONCAT_TARGET : "main.js",
        // Images
        IMAGE_SRC : "src/images/**/*",
        IMAGE_DEST : "dist/assets/img",
        // Live reload
        LIVE_RELOAD_PORT : 35729
    };
    
    
    // Compile Our Sass
    gulp.task('sass', function() {
        return gulp.src( options.SASS_SOURCE )
            .pipe(plumber())
            .pipe(sass({
                //includePaths: ['./sass'],
                outputStyle: 'expanded'
                }))
            .on("error", notify.onError())
            .on("error", function (err) {
                console.log("Error:", err);
            })
            .pipe(prefix(
                "last 1 version", "> 10%"
                ))
            .pipe(gulp.dest(options.CSS_DEST))
            .pipe(livereload(server));
    });
    
    
    
    gulp.task('default', function () {
      gulp.watch( options.SASS_SOURCE , ['sass']);
    });
    
    gulp.task('lr', function () {
      server.listen( options.LIVE_RELOAD_PORT , function (err) {
        if (err) return console.log(err);
    
        // Watch .SCSS files
        gulp.watch( options.SASS_SOURCE , function (event) {
            console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
            gulp.run('sass');
        });
    
      });
    });
    
  3. yocontra commented on Feb 1, 2014

    @yocontra
    Member

    By not returning it the task system doesn't wait for the stream to finish before ending the task. It has always taken 269ms and removing return is just going to change your logs to say otherwise

  4. lmartins commented on Feb 1, 2014

    @lmartins
    Author

    Thanks @contra , if im understanding correctly it has no effect performance wise, is just the way it communicates times then.

    I think gulp gave me a speed addiction problem :-)

  5. yocontra commented on Feb 1, 2014

    @yocontra
    Member

    @lmartins Also the way task dependencies work. If you don't return the stream from a and b has a dependency on it then they will both end up running at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions