Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp-compass compressing sass not working

Running Sass 3.4.3, Compass 1.0.1, Gulp 3.8.8 and Gulp-compass 1.3.1

gulp.task('compass', function() {
    gulp.src('comp/sass/style.scss')
        .pipe(compass({
            sass: 'comp/sass',
            image: 'dev/theme/images',
            style: 'compressed'
        })
        .on('error', gutil.log))
        .pipe(gulp.dest('dev/theme/css'))
});

The Compass task is compiling the sass but compression is not working. It outputs a normal uncompressed CSS file.

like image 478
Avin Varghese Avatar asked Sep 12 '14 12:09

Avin Varghese


Video Answer


1 Answers

I had the same issue with the following:

gulp.task('compass', function() {
    gulp.src(sassSources)
     .pipe(compass({
        sass: 'components/sass',
        image: outputDir + '/images',
        style: sassStyle
     }))
     .on('error', gutil.log)
     .pipe(gulp.dest(outputDir + '/css'))
     .pipe(connect.reload())
});

Note that there is this variable sassStyle that is defined conditionally in this next portion of code where the node.js process.env process is 'watching' NODE_ENV value so we can switch between production folder and development folder:

env = process.env.NODE_ENV || 'development';
 if (env ==='development') {
    outputDir = 'builds/development/';
    sassStyle = 'expanded';
} else {
    outputDir = 'builds/production/';
    sassStyle ='compressed';
}

It didn't do the trick but an external config.rb file manually edited with:

config_file: 'config.rb',

with this line in the file worked:

output_style = :compressed

For now, I just left these lines commented out in the file as workaround.

I'm using the following devDependencies:

  "devDependencies": {
    "gulp": "^3.9.1",
    "gulp-browserify": "^0.5.1",
    "gulp-coffee": "^2.3.2",
    "gulp-compass": "^2.1.0",
    "gulp-concat": "^2.6.0",
    "gulp-connect": "^5.0.0",
    "gulp-util": "^3.0.7",
    "jquery": "^3.1.0",
    "mustache": "^2.2.1"
  }
like image 149
Massamba Sow Avatar answered Nov 07 '22 16:11

Massamba Sow