2015-10-14 23 views
0

我有d:/了projectA
工作SASS預處理器的Node.js通過咕嚕

Gruntfile.js

module.exports = function(grunt) { 

// Project configuration. 
grunt.initConfig({ 

    //Read the package.json (optional) 
    pkg: grunt.file.readJSON('package.json'), 

    // Metadata. 
    meta: { 
     basePath: '../', 
     srcPath: '../', 
     deployPath: '../' 
    }, 

    banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + 
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' + 
      '* Copyright (c) <%= grunt.template.today("yyyy") %> ', 

    // Task configuration. 
    concat: { 
     options: { 
      stripBanners: true 
     }, 
     dist: { 
      src: ['<%= meta.srcPath %>engine/css/mycss1.css', '<%= meta.srcPath %>engine/css/mycss2.css'], 
      dest: '<%= meta.deployPath %>engine/css/00myfinal.css' 
     } 
    }, 

    //the Sass Task 
    sass: { 
     sass_my_files : { 

      files : { 
       //"the Destination " : " the source files" 
       "../engine/css/mystyle3.css" : "../engine/css/mysass1.scss", 
      }, 
      options : { 
       "style":"compressed", 
       "precision":"7" 
      }, 
     }, 
    }, 

}); 

// These plugins provide necessary tasks. 
grunt.loadNpmTasks('grunt-contrib-concat'); 
grunt.loadNpmTasks('grunt-contrib-sass'); 

// Default task 
grunt.registerTask('default', ['concat','sass']); 

}; 

的package.json

{ 
    "name": "Test-Project", 
    "version": "0.1.0", 
    "devDependencies": { 
    "grunt": "~0.4.1", 
    "grunt-contrib-concat": "~0.1.3" 
    } 
} 

安裝在我的「紅寶石的Windows 」。

插入下面的命令:

npm install ruby-sass 

我完成這一切。但在運行「咕嚕」的命令,我得到錯誤:

You need to have Ruby and Sass installed and in your path for this task to work. 

誰能告訴爲什麼我的控制檯顯示錯誤它成功運行的「CONCAT」任務後,並顯示在「錯誤SASS'任務?

回答

1

使用npm install -g ruby-sass,它在您的環境變量中全局安裝ruby-sass gem。然後繼續。

我建議在Grunt上使用Gulp。它們的功能類似,但我更喜歡Gulp,因爲它是管道資產。值得肯定的學習。