gulp-sass: Stops writing CSS after first error in SASS
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 replace gulp-sass
with gulp-less
, so I thought maybe this is a gulp-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:
- When SASS files are error free, I see ‘Writing sass’ message each time I update a
*.scss
file. - Then, I deliberately introduce an error into one of the SASS files. I see an error message from
gulp-plumber
as I should. - However, when I undo this error, I no longer see “Writing sass” message and no CSS files are being written to the
.build/
directory. I need to restartgulp watch-sass
task to make things go back to normal.
# In gulpfile.coffee
sass = require("gulp-sass")
... ... ...
gulp.task "watch-sass", ->
watch
glob: filePath.appDir + "/**/*.scss"
.pipe plumber()
.pipe sass() # the problem goes away if I replace `sass` with `less`
.pipe using prefix: "Writing sass"
.pipe gulp.dest('.build/')
return
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 3
- Comments: 23 (1 by maintainers)
Commits related to this issue
- apply fix to bug in gulp-sass -> https://github.com/dlmanning/gulp-sass/issues/90#issuecomment-100021202 — committed to MozaikAgency/wp-theme-starter by Maximilianos 9 years ago
- Fix CSS not ending up in the build Because we weren't returning the stream, `html` task wasn't waiting for it to finish. https://github.com/dlmanning/gulp-sass/issues/90#issuecomment-100021202 — committed to yeoman/generator-webapp by silvenon 9 years ago
- Don't leave me hanging. Ref: https://github.com/dlmanning/gulp-sass/issues/90#issuecomment-112052541 — committed to digitoimistodude/devpackages by deleted user 9 years ago
I just re-tested this and it seems to be working fine when using
.on('error', sass.logError)
. Can someone double check this for me? @dlmanning @Keats @demisxSpecifically, what I was running is as follows:
Running
sass:watch
Hi, I found this issue after researching a bit about how to use
gulp-sass
with plumber. I understood that in order to keep the watch task alive I need to either:return
statement for the pipeHowever I don’t think this is an optimal solution because either you loose:
return
and don’t thus don’t return the streamAnd 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:
What do you guys think? I’m switching from
gulp-ruby-sass
togulp-sass
and I would really like to see this working ingulp-sass
as well!I understand people are still having issues, so for those who are, please try the following:
return
the task innards)return
the task innards and uses Gulp Plumber)If neither of these things work for you, please provide the following:
Gulpfile.js
,package.json
, and Sass filesI had to switch to the sync version to make this work.
Not working:
Working:
OS X Yosemite Node 0.10.38 gulp 3.8.11 gulp-plumber 1.0.0 gulp-sass 2.0.0