2015-08-24 42 views
0

我是使用gulpjs的新手。在我使用SASS和Compass之前。我跟着这个教程http://ericlbarnes.com/setting-gulp-bower-bootstrap-sass-fontawesome/Gulp.js sass css编译非常慢

这一切工作正常,但sass编译非常慢,这是烦人的。

我这是我的代码:

var gulp = require('gulp'),
   
    sass = require('gulp-ruby-sass')
  
    notify = require("gulp-notify")
  
    bower = require('gulp-bower'); 

var config = { 

  sassPath: './scss', 

  bowerDir: './bower_components'
  
} 


gulp.task('css', function() {
  
    return gulp.src(config.sassPath + '/style.scss') 

   .pipe(sass({ 

    style: 'compressed', 

    loadPath: [ 

     './scss', 

     config.bowerDir + '/bootstrap-sass-official/assets/stylesheets', 

     config.bowerDir + '/fontawesome/scss', 

    ] 

   })
  
      .on("error", notify.onError(function (error) { 

     return "Error: " + error.message; 

    })))
  

   .pipe(gulp.dest('./public/css'));
  
}); 

gulp.task('bower', function() {
  
    return bower() 

   .pipe(gulp.dest(config.bowerDir))
  
}); 

gulp.task('icons', function() {
  
    return gulp.src(config.bowerDir + '/fontawesome/fonts/**.*')
  
     .pipe(gulp.dest('./public/fonts'));
  
}); 


// Rerun the task when a file changes 

 gulp.task('watch', function() { 

  gulp.watch(config.sassPath + '/**/*.scss', ['css']);
  
}); 


 
 gulp.task('default', ['bower', 'icons', 'css']); 
+1

没有读入太多,使用Ruby宝石已知是比使用['吞掉-sass']慢得多(https://www.npmjs.com/包/ gulp-sass)通过'libsass'进行编译。 – Oka

+0

谢谢我会检查出来。 – weaveoftheride

回答

0

我换吞掉 - 萨斯的建议。

我的代码:

var gulp = require('gulp'), 
sass = require('gulp-sass') 
notify = require("gulp-notify")
  
bower = require('gulp-bower'); 

var config = {
  
    sassPath: './scss', 
    
 bowerDir: './bower_components'
  
} 

gulp.task('css', function() { 
     gulp.src(config.sassPath + '/style.scss') 
      .pipe(sass({
  
        style: 'compressed', 
        includePaths: [
 './scss', 
        config.bowerDir + '/bootstrap-sass-official/assets/stylesheets', 
  
        config.bowerDir + '/fontawesome/scss', 
 ]
  
       }) 
       .on("error", notify.onError(function(error) {
  
        return "Error: " + error.message;
  
       })))
  


   .pipe(gulp.dest('./public/css'));
  
}); 



gulp.task('bower', function() {
  
    return bower()
 .pipe(gulp.dest(config.bowerDir))
  
}); 

gulp.task('icons', function() {
  
    return gulp.src(config.bowerDir + '/fontawesome/fonts/**.*')
  
     .pipe(gulp.dest('./public/fonts'));
  
}); 


// Rerun the task when a file changes 

  
gulp.task('watch', function() {
  
    gulp.watch(config.sassPath + '/**/*.scss', ['css']);
  
}); 


 
  
gulp.task('default', ['bower', 'icons', 'css']);