2015-08-24 43 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']);