2016-07-15 48 views
0

我正在使用Grunt將通過監視將我的SASS文件轉換爲CSS。使用Grunt Watch將SASS轉換爲CSS致命錯誤

的事情是:我可以normaly運行北斗任務時,CSS創建的非常好,但是當我使用WATCH我得到了錯誤:

grunt.util._.contains is not a function

這裏是我的package.json

{ 
    "name": "myName", 
    "description": "myDesc", 
    "author": "mySelf", 
    "version": "0.0.1", 
    "private": true, 
    "devDependencies": { 
     "grunt": "^1.0.1", 
     "grunt-contrib-compass": "^1.1.1", 
     "grunt-contrib-jshint": "^0.10.0", 
     "grunt-contrib-nodeunit": "~0.4.1", 
     "grunt-contrib-sass": "^1.0.0", 
     "grunt-contrib-uglify": "^0.5.1", 
     "grunt-contrib-watch": "^0.4.4" 
    } 
} 

這裏是我的Gruntfile.js

module.exports = function(grunt) { 
    grunt.initConfig({ 
     pkg: grunt.file.readJSON('package.json'), 
     compass: { 
      dist: { 
       options: { 
        config: 'config.rb' 
       } 
      } 
     }, 
     watch: { 
      css: { 
       files: 'assets/**/*.{scss,sass}', 
       tasks: ['compass'] 
      } 
     } 
    }); 
    grunt.loadNpmTasks('grunt-contrib-compass'); 
    grunt.loadNpmTasks('grunt-contrib-watch'); 
    grunt.registerTask('default',['compass','watch']); 
}; 

我嘗試了很多的變化,但沒有什麼幫助

Update!

After a long night, solve the problem... Please read my own answer

回答

5

我解決了這個問題!^4.0 lodash版本已更改包含包括,並且grunt-contrib-watch使用舊的lodash語法。所以我只更改了代碼中的一行。查找線路116 node_modules/grunt-contrib-watch/tasks/watch.js

舊線:

if (!grunt.util._.contains(target.options.event, 'all') && !grunt.util._.contains(target.options.event, status)) {

新線:

if (!grunt.util._.includes(target.options.event, 'all') && !grunt.util._.includes(target.options.event, status)) {

現在手錶指南針/ SASS就像一個魅力;)

希望它有助於某人!