Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite looping #411

Closed
ryanaltvater opened this issue Jul 28, 2015 · 1 comment
Closed

Infinite looping #411

ryanaltvater opened this issue Jul 28, 2015 · 1 comment

Comments

@ryanaltvater
Copy link

When I make a change to a SCSS file, both "scss" and "css" tasks run and somehow end up in an infinite loop because the "css" task is watching my SCSS files for changes (Option 1). I've tried a few different approaches to try and solve this, but the only thing that seems to work is not having CSScomb run automatically and instead manually. That's not the desire, but it works.

What might I be doing wrong? I realize the "watch" task might be the issue, but I've removed the "scss" task from "watch" and put it directly on the "css" task (Option 2). I've also duplicated the "watch" and split the tasks (Option 3). It makes sense why it's looping. I just can't figure out a way to prevent it.

Option 1:

/* ============================== */
/*  SCSS
/* ============================== */

gulp.task('scss', function() {
    return gulp.src([
        srcSCSS         + '**/*.scss',
        '!' + srcSCSS   + 'bourbon/**/*',
        '!' + srcSCSS   + 'neat/**/*'
    ])
    .pipe(csscomb())
    .pipe(gulp.dest(srcSCSS));
});


/* ============================== */
/*  CSS
/* ============================== */

gulp.task('css', function() {
    return gulp.src([
        srcSCSS         + 'styles.scss'
    ])
    .pipe(plumber({
        errorHandler    : notify.onError('Error: <%= error.message %>')
    }))
    .pipe(sass())
    .pipe(autoprefixer({
        browsers        : ['last 2 versions'],
        cascade         : false
    }))
    .pipe(cmq())
    .pipe(cssmin())
    .pipe(header(banner, {
        package         : package
    }))
    .pipe(gulp.dest(destCSS))
    .pipe(reload({
        stream          : true
    }));
});


/* ============================== */
/*  WATCH
/* ============================== */

gulp.task('watch', function() {
    gulp.watch(srcCSS   + '**/*.scss', ['scss', 'css']);
});

Option 2:

/* ============================== */
/*  SCSS
/* ============================== */

gulp.task('scss', function() {
    return gulp.src([
        srcSCSS         + '**/*.scss',
        '!' + srcSCSS   + 'bourbon/**/*',
        '!' + srcSCSS   + 'neat/**/*'
    ])
    .pipe(csscomb())
    .pipe(gulp.dest(srcSCSS));
});


/* ============================== */
/*  CSS
/* ============================== */

gulp.task('css', ['scss'], function() {
    return gulp.src([
        srcSCSS         + 'styles.scss'
    ])
    .pipe(plumber({
        errorHandler    : notify.onError('Error: <%= error.message %>')
    }))
    .pipe(sass())
    .pipe(autoprefixer({
        browsers        : ['last 2 versions'],
        cascade         : false
    }))
    .pipe(cmq())
    .pipe(cssmin())
    .pipe(header(banner, {
        package         : package
    }))
    .pipe(gulp.dest(destCSS))
    .pipe(reload({
        stream          : true
    }));
});


/* ============================== */
/*  WATCH
/* ============================== */

gulp.task('watch', function() {
    gulp.watch(srcCSS   + '**/*.scss', ['css']);
});

Option 3:

/* ============================== */
/*  SCSS
/* ============================== */

gulp.task('scss', function() {
    return gulp.src([
        srcSCSS         + '**/*.scss',
        '!' + srcSCSS   + 'bourbon/**/*',
        '!' + srcSCSS   + 'neat/**/*'
    ])
    .pipe(csscomb())
    .pipe(gulp.dest(srcSCSS));
});


/* ============================== */
/*  CSS
/* ============================== */

gulp.task('css', function() {
    return gulp.src([
        srcSCSS         + 'styles.scss'
    ])
    .pipe(plumber({
        errorHandler    : notify.onError('Error: <%= error.message %>')
    }))
    .pipe(sass())
    .pipe(autoprefixer({
        browsers        : ['last 2 versions'],
        cascade         : false
    }))
    .pipe(cmq())
    .pipe(cssmin())
    .pipe(header(banner, {
        package         : package
    }))
    .pipe(gulp.dest(destCSS))
    .pipe(reload({
        stream          : true
    }));
});


/* ============================== */
/*  WATCH
/* ============================== */

gulp.task('watch', function() {
    gulp.watch(srcCSS   + '**/*.scss', ['scss']);
    gulp.watch(srcCSS   + '**/*.scss', ['css']);

// or

    gulp.watch(srcCSS   + '**/*.scss', ['css']);
    gulp.watch(srcCSS   + '**/*.scss', ['scss']);
});
@tonyganch
Copy link
Member

Duplicate of koistya/gulp-csscomb#20
Until everyone is certain the issue is with csscomb itself and not gulp task, I'm closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants