Search code examples
csssassgulpcompass

Compass Line Number Comments Not Showing Up with Gulp


I am attempting to make the switch from GruntJS to Gulp and have run into a problem with my Gulp task for processing my SASS files via Compass. The files compile just fine into the single CSS file as they did under my GruntJS implementation, but I am missing the line number comments that show me where the CSS rules come from such as: /* line 26, ../_components/sass/_base.scss */

The code from my gulpfile.js for the task is:

gulp.task('compass', function() {
   gulp.src(sassSources)
     .pipe(compass({
        comments: true,
        sass: '_components/sass', 
        image: 'builds/dev/images',
        style: 'nested'
   })
   .on('error', gutil.log))
   .pipe(gulp.dest('builds/dev/css'))
});

Am I missing something?


Solution

  • Be careful with gulp-compass, it is not a gulp plugin (albeit named so) and has been blacklisted by the Gulp community for quite a while. It does not what Gulp plugins are supposed to do (e.g. it's possible to run them without gulp.src and gulp.dest), and other plugins are already doing its work perfectly fine. One of those plugins is gulp-ruby-sass. This setup might work for you:

    var sass = require('gulp-ruby-sass');
    gulp.task('compass', function() {
       return sass(sassSources, {
         compass: true,
         lineNumbers: true
       }).on('error', gutil.log))
       .pipe(gulp.dest('builds/dev/css'))
    });
    

    This uses gulp-ruby-sass which is able to run with the compass extension. You see that I activated lineNumbers here to give you said output.

    I see from your Gulpfile that you might have some extension requiring some images, I don't know exactly what that does, but if it's mandatory to your setup, you might better call compass directly (the command line tool) using require('child_process').exec(...)