2017-04-25 67 views
1

根據this,可以使用Gulp從Ruby編譯susy install。 但是,由於性能和棄用,是否可以使用gulp-sass而不是gulp-compass或gulp-ruby-sass? 其實我在gulpfile.js使用:處理Gulp,Bundler,Ruby和Susy

gulpfile

var gulp = require('gulp'); 

// Include plugins 
var plugins = require('gulp-load-plugins')(); 

// Variables de chemins 
var source = './sass/**/*.scss'; // dossier de travail 
var destination = './css/'; // dossier à livrer 

gulp.task('sasscompil', function() { 
    return gulp.src(source) 
    .pipe(plugins.sass({ 
     outputStyle: 'compressed', 
     includePaths: ['/home/webmaster/vendor/bundle/gems/susy-2.2.2/sass'] 
    }).on('error', sasscompil.logError)) 
    .pipe(plugins.csscomb()) 
    .pipe(plugins.cssbeautify({indent: ' '})) 
    .pipe(plugins.autoprefixer()) 
    .pipe(gulp.dest(destination + '')); 
}); 

但錯誤日誌不起作用,因爲sasscompil沒有定義。 然後,我需要給所有前指南針包括像susy,時髦按鈕等路徑。 是否有可能給寶石的全球路徑? 其他的事情,儘管使用了gulp-load-plugins,我還能安裝gulp插件嗎?因爲如果我不這樣做,gulp不會找到插件。

感謝

+1

嘗試改變'sasscompil'到'plugins.sass.logError' - 可以在下面留下一個答案。 (我們將錯誤傳遞迴'node-sass',它被'gulp-sass'用來輸出錯誤)[ref](https://github.com/dlmanning/gulp-sass#options) –

+0

did上述工作? –

+0

是的,更改爲''plugins.sass.logError''給我''插件'sass'錯誤 消息: sass/application.scss 錯誤:導入文件不存在或不可讀:sassy-buttons。 父級樣式表:/var/www/drupal-6/sites/all/themes/starter-susy2-nc-d6/sass/application.scss on line 33 of sass/application.scss '' –

回答

1

您需要更改sasscompil.logErrorplugins.sass.logError

這樣

gulpfile.js

gulp.task('sasscompil', function() { 
    return gulp.src(source) 
    .pipe(plugins.sass({ 
     outputStyle: 'compressed', 
     includePaths: ['/home/webmaster/vendor/bundle/gems/susy-2.2.2/sass'] 
    }).on('error', plugins.sass.logError)) 
... 
}); 

一飲而盡,薩斯DOC:

Pass in options just like you would for node-sass; they will be passed along just as if you were using node-sass. Except for the data option which is used by gulp-sass internally. Using the file option is also unsupported and results in undefined behaviour that may change without notice.

例如

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