sass - grunt 说没有找到 "sass"目标

标签 sass gruntjs

我正在尝试设置 grunt-contrib-sass,以便可以使用 grunt 处理 sass-to-css 编译。我在使用 grunt init:makefile 搭建了一个基本的 grunt 文件后安装了它。当我运行 grunt sass 只是为了测试东西时,终端返回一个“没有找到”sass“目标。”

我的设置:

  • $sass -v 返回“Sass 3.2.1”

  • $ruby -v 返回“ruby 1.9.3p194”

  • “node_modules”文件夹包含“grunt-contrib-sass”

  • 基于 grunt-contrib-sass 文档,我的 grunt.js 文件目前如下所示:

module.exports = function(grunt) {

grunt.initConfig({
lint: {
  files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js']
},
test: {
  files: ['test/**/*.js']
},
watch: {
  files: '<config:lint.files>',
  tasks: 'lint test'
},
jshint: {
  options: {
    curly: true,
    eqeqeq: true,
    immed: true,
    latedef: true,
    newcap: true,
    noarg: true,
    sub: true,
    undef: true,
    boss: true,
    eqnull: true
  },
  globals: {},
   sass: {                                     // Task
    dist: {                                 // Target
        files: {                            // Dictionary of files
            'main.css': 'main.scss',        // 'destination': 'source'
            'widgets.css': 'widgets.scss'
        }
    },
    dev: {                                  // Another target
        options: {                          // Target options
            style: 'expanded'
        },
        files: {
            'main.css': 'main.scss',
            'widgets.css': [
                'button.scss',
                'tab.scss',
                'debug.scss'                
            ]
        }
    }
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');

grunt.registerTask('default', 'lint sass');

};

感谢任何和所有帮助...非常感谢!

最佳答案

仔细检查你的右花括号。您的 sass block 在您的 jshint block 内。试试这个:

module.exports = function(grunt) {
grunt.initConfig({
  lint: {
    files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js']
  },
  test: {
    files: ['test/**/*.js']
  },
  watch: {
    files: '<config:lint.files>',
    tasks: 'lint test'
  },
  jshint: {
    options: {
      curly: true,
      eqeqeq: true,
      immed: true,
      latedef: true,
      newcap: true,
      noarg: true,
      sub: true,
      undef: true,
      boss: true,
      eqnull: true
    },
    globals: {},
  },
  sass: {                                   // Task
    dist: {                                 // Target
        files: {                            // Dictionary of files
            'main.css': 'main.scss',        // 'destination': 'source'
            'widgets.css': 'widgets.scss'
        }
    },
    dev: {                                  // Another target
        options: {                          // Target options
            style: 'expanded'
        },
        files: {
            'main.css': 'main.scss',
            'widgets.css': [
                'button.scss',
                'tab.scss',
                'debug.scss'                
            ]
        }
    }
}
});
grunt.loadNpmTasks('grunt-contrib-sass');

grunt.registerTask('default', 'lint sass');

};

关于sass - grunt 说没有找到 "sass"目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12789746/

相关文章:

html - 有没有办法连接 CSS 类选择器?

angular - 如何在 ngx-admin 主题中使用主题颜色

makefile - 什么是生成文件?它与 Gruntfile 或 npm run 有何不同?

javascript - 交叉类型阻止编译

css - 如何修复SCSS中的 undefined variable 错误?

css - 如何在不复制库的情况下在 Angular 组件的 CSS 中使用第三方 CSS 库?

javascript - 运行 Node.js(在 Windows R2 服务器上): How can I reduce the amount of RAM that my grunt tasks consume?

javascript - 运行跨多个 grunt.js 文件配置的任务

javascript - 在具有多个子目录的大型 Javascript 项目上使用 grunt

sass - 是否可以不赞成使用sass/scss mixin?