IAMMRBONGO
IAMMRBONGO

Reputation: 73

Gulp-sass compressed style doesn't seem to work for me when trying to compile and output sourcemaps

I'm trying to get my gulp pipeline working for a site but it doesn't seem to want to compress the scss, I've got all the sass compiling into a single css file but the file isn't compressed. I tried changing the raw files under node_modules thinking it may refresh the cache or something but it looks like this style doesn't work or that it doesn't to what I think it does.

function css() {
   return gulp
       .src('./scss/*.scss')
       .pipe(sourcemaps.init())
       .pipe(sass({ style: 'compressed' }).on('error', sass.logError))
       .pipe(sourcemaps.write('./'))
       .pipe(gulp.dest('./css'));
}

Thanks

Upvotes: 1

Views: 2758

Answers (2)

Adam Šipický
Adam Šipický

Reputation: 848

For those who are interested about possible values of outputStyle

  • nested
  • expanded
  • compact
  • compressed

f.e. with Gulp you could use it like .pipe(sass(outputStyle: 'expanded'))

(source https://inchoo.net/dev-talk/tools/sass-output-styles/)

Upvotes: 2

Cody MacPixelface
Cody MacPixelface

Reputation: 1386

So close, you need to change style with outputStyle and it should work.

See examples in the options section for gulp-sass.

function css() {
   return gulp
       .src('./scss/*.scss')
       .pipe(sourcemaps.init())
       .pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
       .pipe(sourcemaps.write('./'))
       .pipe(gulp.dest('./css'));
}

Upvotes: 1

Related Questions