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')) }); 

compass The task is to compile sass, but compression does not work. It outputs a regular uncompressed css file.

+5
source share
2 answers

I had the same problem 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 sassStyle variable, which is conditionally defined in the next part of the code, where the node.js process.env process is the β€œobserving” value of NODE_ENV, so we can switch between the production folder and the development folder:

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

This is not a trick, but an external config.rb file edited manually:

 config_file: 'config.rb', 

with this line in the file:

 output_style = :compressed 

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

I am 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" } 
+1
source

What you have should work, but I think the gulp-compass plugin is a bit wrong with the settings. It works sequentially for me with the output style in a separate config.rb file.

 var gulp = require('gulp'); var compass = require('gulp-compass'); var gutil = require('gulp-util'); gulp.task('compass', function() { return gulp.src('comp/sass/style.scss') .pipe(compass({ config_file: 'config.rb', sass: 'comp/sass', image: 'dev/theme/images' }) .on('error', gutil.log)) .pipe(gulp.dest('dev/theme/css')) ; }) 

With this in config.rb file:

 output_style = :compressed 
0
source

Source: https://habr.com/ru/post/1202422/


All Articles