BlessCSS/gulp-bless

Cleanup not working properly with gulp-bless

cyberixae opened this issue · 6 comments

I spent some time debugging why cleanups are not working in gulp-bless. If I understand correctly the problem is that gulp-bless needs to call the bless.Parser.cleanup method explicitly.

The call is missing from gulp-bless https://github.com/BlessCSS/gulp-bless/blob/master/index.js
While it is present in the old command line tool https://github.com/BlessCSS/bless/blob/3.x/bin/blessc

It is possible that gulp-bless uses a different version of the library with a different API. Either way, the cleanup does not seem to work.

There is a related problem in Bless which causes cleanups to fail when cache buster is being used BlessCSS/bless#88 However I disabled cache buster before filing this bug so the gulp-bless bug should be a separate problem.

Sorry I missed this until now. I've just redone this as Bless 4 completely changes things. See #21. Bless has dropped that method. What did you use it for?

We had a git repository for static hosting and a gulp task that would generate some blessed CSS files in there. Some of the files were actual static content so creating a gulp task to remove the entire directory before CSS regeneration was not an option. Anything that created a single output CSS file would simply override the old one. The problematic scenario was then using bless when the CSS output got shorter because that left unnecessary files in the repository. This was of course possible to fix with a custom cleanup task that would hand tuned to only remove the relevant files. However "official" bless cleanup would have been nice for two reason 1) no need to maintain the separate gulp task 2) git status would look better during compilation since the blessed files would not temporarily disappear

@cyberixae ah ok. I'm afraid you'll have to create a custom gulp task. Bless has removed intentionally removed this.

I could add this but it clashes with the way gulp plugins are meant to work. I have no idea where you're going to put the files (when you eventually gulp.dest). Even if I accepted a parameter to accept a path/glob (i.e. where to cleanup) then this is messy and generally not what a gulp plugin should do. A gulp plugin should be really simple (do only one thing well, if possible). This plugin shouldn't touch disk really, it should just manipulate the files in memory and you'd save them later when you gulp.dest or whatever. I see that grunt-bless has this option but I'm not surprised as this distinction is always listed as one of the reasons why gulp is better than grunt.

I hope that's ok. Thanks anyway for explaining.

I think it is possible to also write deletions into gulp streams in a relative manner. Ofcourse with bless there is the problem that you wouldn't know how many files need to be deleted. Maybe the previous input created 10 CSS files and the current one creates only 2. You would then somehow know to delete files 3-10. Maybe it is indeed better to just have a separate clean up task in gulp.

I think it is possible to also write deletions into gulp streams in a relative manner.

Yes, relative to the input files, but that doesn't cover something like this:

gulp.src('./a/*.css')
  .pipe(bless())
  .pipe(somethingElse())
  .pipe(somethingElse2())
  .pipe(somethingElse3())
  .pipe(gulp.dest('./somewhere-else'))
  .pipe(somethingElse4())
  .pipe(gulp.dest('./another-copy-somewhere-else'))

Maybe it is indeed better to just have a separate clean up task in gulp.

Yeah.