Compass mixins with Gulp

微笑、不失礼 提交于 2020-01-17 08:00:08

问题


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 !


回答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'));

});



回答2:


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.



来源:https://stackoverflow.com/questions/41848108/compass-mixins-with-gulp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!