0

Is there a way to use Compass mixins with Gulp ? How to use them ?

I tried to use Compass on my Gulp project but each time I get an error with my Compass @import.

Thanks in advance !

Pierre Météyé
  • 143
  • 1
  • 1
  • 10

2 Answers2

1

It's even simpler to use compass-importer. Install it with

npm install --save-dev compass-importer

require it in your gulpfile.js and add importer: compass to sass options

var gulp = require('gulp')
var sass = require('gulp-sass')
var compass = require('compass-importer')

gulp.task('sass', function()
{
return gulp.src('sass/**/*.scss')
  .pipe(sass({ importer: compass }).on('error', sass.logError))
  .pipe(gulp.dest('./css'));

});
Sharak
  • 888
  • 8
  • 17
  • This worked great! I had an old project and wanted to get away from compass. – NickStees Mar 21 '18 at 13:28
  • @NickStees Compass has been depreciated for at least 2 years now, so it's a must to switch to something much faster like node-sass/gulp-sass – Sharak Mar 22 '18 at 13:49
0

First, you need to install the npm compass-mixins package, as so:

npm install compass-mixins --save-dev

Then, add a custom pipe for it, something similar to this:

.pipe(function() {
    return $.if('*.scss', $.sass({
      outputStyle: 'nested', 
      includePaths: [
       './node_modules/compass-mixins/lib'
      ]
    }));
  })

More detailed info in this thread.

Tanasos
  • 3,928
  • 4
  • 33
  • 63