【问题标题】:grunt says no "sass" targets foundgrunt 说没有找到“sass”目标
【发布时间】:2012-09-29 04:15:12
【问题描述】:

我正在尝试设置 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 gruntjs


    【解决方案1】:

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

    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');
    
    };
    

    【讨论】:

    • 我的一个典型的新手错误...感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 2017-09-06
    • 1970-01-01
    • 2014-08-07
    • 1970-01-01
    • 1970-01-01
    • 2018-03-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多