首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Grunt Watch将SASS转换为CSS时发生致命错误

使用Grunt Watch将SASS转换为CSS时发生致命错误
EN

Stack Overflow用户
提问于 2016-07-15 06:31:23
回答 1查看 1.2K关注 0票数 1

我正在使用Grunt生活,通过观看将我的SASS文件转换为CSS。

问题是:我可以正常运行Compass任务,CSS很好地创建,但是当我使用WATCH时,我得到了错误:

grunt.util._.contains不是一个函数

这是我的package.json

代码语言:javascript
复制
{
    "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

代码语言:javascript
复制
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']);
};

我尝试了很多改变,但没有任何帮助。

更新! 经过漫长的一夜,解决了问题..。请读我自己的答案

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-15 21:47:21

我解决了问题!^4.0 lodash版本已将contains更改为includes,并且grunt-contrib-watch使用了旧的送交语法。所以我只修改了代码中的一行。在第116行找到node_modules/grunt-contrib-watch/tasks/watch.js

老台词:

如果(!grunt.util._.contains(target.options.event,‘all’&& !grunt.util._.contains(target.options.event,状态){

新项目:

如果(!grunt.util._.includes(target.options.event,‘all’&& !grunt.util._.includes(target.options.event,状态){

现在,使用Compass/SASS的手表工作起来就像一种魅力;)

我希望它能帮到别人!

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38389280

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档