-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Stops writing CSS after first error in SASS #90
Comments
I am also seeing this as well when using gulp.task('css', function() {
return gulp.src('css/**/*.scss')
.pipe(plugins.plumber())
.pipe(plugins.sass({ outputStyle: 'compressed'}))
.pipe(gulp.dest('../css'));
});
gulp.task('watch', function() {
gulpWatch.watch('css/**/*.scss', function (files, cb) {
gulp.start('css', cb);
});
}); In my case, if I introduce an error in my scss file, an error is thrown by plumber and the watch task does not terminate. However, if I fix the error, I can see that watch sees the change, but sass does not attempt to recompile the file. |
This is quite annoying. One typo and sass building of css dies, I have to restart gulp watch and refresh all the browsers. Is there any way to get around this or fix it? |
A workaround is to retrieve files via a callback rather than pipe: gulp.task "watch-sass", ->
watch filePath.appDir + "/**/*.scss", (files) ->
files.pipe plumber()
.pipe sass()
.pipe using prefix: "Writing sass"
.pipe gulp.dest('.build/') |
pretty frustrating to have to restart gulp watch, kinda defeats the purpose.. |
I can confirm this is still happening in the 2.x branch; we will need to figure this out before releasing. |
I just re-tested this and it seems to be working fine when using
Specifically, what I was running is as follows: 'use strict';
var gulp = require('gulp'),
sass = require('gulp-sass');
gulp.task('sass', function () {
gulp.src('./sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
gulp.task('sass:watch', function () {
gulp.watch('./sass/**/*.scss', ['sass']);
}); Running |
I've tried a bunch of iterations on the above that's working and I cannot get it to fail again. I'm closing this; if someone can find a repeatable way to produce this error in the 2.x branch, we can consider reevaluating. |
@Snugug I've installed gulp-sass@next (before that I cleaned npm cache) and it still stops piping file after an error occurs. I don't know how you made it work :( |
@sqal Try using the code in #90 (comment) |
@Snugug oh ok, now I see my mistake: My task before:
Your is without return on src. Now it works great for me! :) Thanks. |
I had to switch to the sync version to make this work. Not working: gulp.task('css', function() {
return gulp.src('./source/assets/css/*.scss')
.pipe(plumber())
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./build/'));
}); Working: gulp.task('css', function() {
return gulp.src('./source/assets/css/*.scss')
.pipe(plumber())
.pipe(sass.sync().on('error', sass.logError))
.pipe(gulp.dest('./build/'));
}); OS X Yosemite |
I understand people are still having issues, so for those who are, please try the following:
If neither of these things work for you, please provide the following:
|
@Snugug the |
Thanks @Snugug! Works for me too without the |
Awesome. So I'm closing again and am going to write something up in the Wiki about this |
Because we weren't returning the stream, `html` task wasn't waiting for it to finish. dlmanning/gulp-sass#90 (comment)
Hi, I found this issue after researching a bit about how to use
However I don't think this is an optimal solution because either you loose:
And both of them are great advantages of gulp which I don't want to loose when I'm using gulp-sass. Minimal case, where returning the stream is beneficial for the overall execution time: 'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('build', ['sass', 'some-other-task'], function () {
var stream = gulp.src('.');
// awesome build logic
return stream;
});
gulp.task('sass', function () {
// IMPORTANT:
// 1. stream needs to be returned so 'build' task will wait
// 2. no sync so 'some-other-task' can execute concurrently
return gulp.src('./sass/**/*.scss')
.pipe(sass.on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
gulp.task('sass:watch', function () {
gulp.watch('./sass/**/*.scss', ['sass']);
}); What do you guys think? |
Thanks @Snugug, i just added Here's my full sass task, for the ones who want an example, tho it's in coffeescript ;) gulp.task 'sass', ->
gulp.src options.SASS_SRC
.pipe plumber()
.on 'error', notify.onError()
.on 'error', (err) ->
console.log 'Error:', err
.pipe sass(outputStyle: 'expanded').on "error", sass.logError
.pipe prefix browsers: ["last 2 versions", "> 5%"]
.pipe gulp.dest options.SASS_DEST
.pipe sync.stream()
.pipe notify message: 'Building CSS successful', onLast: true |
I'm still having this issue and no solutions that suits me: I need to return the stream and I need to use the async version. Any update ? |
@Avcajaraville nope. :-( |
@jwogrady I ended up rolling my own implementation with sass-node ;) |
In my case, it the "Source" folder is the same than "Destination" folder, it hangs. |
First, I've reported this issue under floatdrop/gulp-watch#86 thinking it was related to
gulp-watch
, but then I've realized that the issue is gone when I replacegulp-sass
withgulp-less
, so I thought maybe this is agulp-sass
related issue after all.TL;DR:
gulp-sass()
stops piping files to destination after a SASS error occurs. Need to restart gulp for the problem to go away.Detail:
*.scss
file.gulp-plumber
as I should..build/
directory. I need to restartgulp watch-sass
task to make things go back to normal.The text was updated successfully, but these errors were encountered: