使用 Grunt Watch 将 SASS 转换为 CSS 的致命错误
Fatal error using Grunt Watch to convert SASS to CSS
我正在使用 G运行t 通过手表将我的 SASS 文件实时转换为 CSS。
问题是:我可以正常 运行 Compass 任务,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
问题我解决了! ^4.0 lodash
版本已将 contains 更改为 includes,并且 grunt-contrib-watch
使用旧的 lodash 语法。所以我只更改了代码中的一行。寻找
node_modules/grunt-contrib-watch/tasks/watch.js
第 116 行:
旧行:
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)) {
现在带 Compass/SASS 的手表就像一个魅力 ;)
希望对大家有所帮助!
我正在使用 G运行t 通过手表将我的 SASS 文件实时转换为 CSS。
问题是:我可以正常 运行 Compass 任务,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
问题我解决了! ^4.0 lodash
版本已将 contains 更改为 includes,并且 grunt-contrib-watch
使用旧的 lodash 语法。所以我只更改了代码中的一行。寻找
node_modules/grunt-contrib-watch/tasks/watch.js
第 116 行:
旧行:
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)) {
现在带 Compass/SASS 的手表就像一个魅力 ;)
希望对大家有所帮助!