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

Not working with gulp-sass #32

Open
realph opened this issue May 20, 2015 · 17 comments
Open

Not working with gulp-sass #32

realph opened this issue May 20, 2015 · 17 comments

Comments

@realph
Copy link

realph commented May 20, 2015

My terminal still returns an error and breaks my task when there's an error in my Sass. This is what my task looks like:

gulp.task('sass', function() {
  return gulp.src(['./src/scss/*.scss', './src/scss/**/*.scss'])
    .pipe(plumber())
    .pipe(sass({
      includePaths : [
        './lib/basscss/scss',
        './lib/fluidbox/css'
      ],
      outputStyle: 'expanded'
    }))
    .pipe(prefix({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(minifyCSS())
    .pipe(gulp.dest('./_site/public/css'))
    .pipe(gzip())
    .pipe(gulp.dest('./_site/public/css'))
    .pipe(reload({stream: true}))
});

Any idea why it keeps breaking? Any help is appreciated. Thanks in advance!

@JoshLipps
Copy link

+1

@floatdrop
Copy link
Owner

Good news - there is nothing wrong in gulp-sass code, bad news - I have no idea, why error is not watched by plumber.

@realph could you remove all plugins below sass, run and post output?

@floatdrop floatdrop changed the title Gulp Plumber Returning Errors in Sass Not working with gulp-sass May 27, 2015
@realph
Copy link
Author

realph commented May 27, 2015

So when I remove all the plugins below gulp-sass, like so:

gulp.task('sass', function() {
  return gulp.src(['./src/scss/*.scss', './src/scss/**/*.scss'])
    .pipe(plumber())
    .pipe(sass({
      includePaths : [
        './lib/basscss/scss',
        './lib/fluidbox/css'
      ],
      outputStyle: 'expanded'
    }))
});

I still get the same error message, when I deliberately make errors in my CSS. Plumber doesn't seem to be working.

Error in plugin 'gulp-sass'
Message:
    src/scss/components/_cover.scss
  30:3  property "background-i" must be followed by a ':'
Details:
    column: 3
    line: 30
    file: /Volumes/Boba/Work/Sites/realph/src/scss/components/_cover.scss
    status: 1
    messageFormatted: src/scss/components/_cover.scss
  30:3  property "background-i" must be followed by a ':'

@holic
Copy link

holic commented May 28, 2015

@realph Try calling gulp-sass with sass.sync instead of sass.

See https://github.com/dlmanning/gulp-sass/wiki/Common-Issues-and-Their-Fixes#gulp-watch-stops-working-on-an-error for an explanation.

@sandhilt
Copy link

@holic You're right! @realph keep code but remove return.

gulp.task('sass', function() {
gulp.src(...)
.pipe(plumber())
.pipe(sass({...}));
});

@realph
Copy link
Author

realph commented Jun 6, 2015

@sandhilt That seems to have fixed it. Thanks!

@silvenon
Copy link

Hm, it's best to use sync when not returning the stream then, I guess? Otherwise I sometimes get some weird errors because my styles task didn't finish yet.

@joshwiens
Copy link

@holic - GG worked like a charm after your suggestion to "rtfm" :)

@gligoran
Copy link

@sandhilt, @realph : Just be aware that removing return before gulp.src will cause task dependencies to not work as they should. While a dependent task will wait for its dependencies, those dependencies will seem to end before they're actually done. If you have the return dependent task will actually wait for all the streams to end before running.

@joshwiens
Copy link

@gligoran - Yeah and that ended up not being an option for me. I managed to get it working with the return statement after a bit of dinking around.

@TheAggressive
Copy link

@joshtoo how did you get it to work?

@joshwiens
Copy link

@TheAggressive - If you can point me to a repo i'll take a look at your gulp build.

@TheAggressive
Copy link

@joshtoo I got it to work this way:

gulp.task('sass', function() {
  return gulp.src('scss/style.scss')
    .pipe(plumber())
    .pipe(sass.sync({ // Have to use sass.sync - See Issue (https://github.com/dlmanning/gulp-sass/issues/90)
      outputStyle: 'compressed',
      errLogToConsole: true
    }))
    .pipe(autoprefixer({
      browsers: ['last 2 versions', 'ie >= 9']
    }))
    .pipe(gulp.dest('./'));
});

would that do the trick?

@joshwiens
Copy link

@TheAggressive

var $ = require('gulp-load-plugins')({lazy: true}); // John Papa tip for shortening the require list

gulp.task('sass', ['clean-sass'], function() {
    log('SASS Compilation ==> CSS3');

    return gulp
        .src(conf.sass)
        .pipe($.plumber())
        .pipe($.sass())
        .on('error', $.sass.logError)
        .pipe($.autoprefixer({browsers: ['last 2 version', '> 5%']}))
        .pipe(gulp.dest(conf.tempDir));

});

@TheAggressive
Copy link

@joshtoo Thanks!!

@joshwiens
Copy link

@TheAggressive No problem :)

campsjos added a commit to campsjos/generator-rkgttr that referenced this issue Feb 8, 2017
Related to this `gulp-plumber` issue: floatdrop/gulp-plumber#32
Without this fix, gulp watch task breaks when compiler does.
@alextrastero
Copy link

Removing return worked for me

// before
gulp.task('sass', function () {
  return gulp.src(config.sass.input)
    .pipe(plumber())
    .pipe(sass())
})
// after
gulp.task('sass', function () {
  gulp.src(config.sass.input)
    .pipe(plumber())
    .pipe(sass())
})

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

10 participants