javascriptnode.jsgruntjsgrunt-contrib-sass

Grunt task not found (grunt-contrib-sass)


Here's my gruntfile.js, it's in the same directory as sass/style.scss and package.json. package.json has grunt, grunt-contrib-sass and grunt-cli installed.

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    // this is where you set up your Sass settings. Once you know what you're doing, you can change thse.
    Sass: {
      dist: {
        options: {
          style: 'compressed'
        },
        files: {
          'style.css': 'sass/style.scss'
        }
      }
    }
  });
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.registerTask('default', ["Sass"]);
};

Any ideas why I'm receiving the task not found error?


Solution

  • Change Saas to saas as shown in the example config.

    Note: The correct spelling of the Task name starts with a lowercase (s).

    Gruntfile.js

    module.exports = function(grunt) {
      grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        sass: { // <-- Change to lowercase `s`
          dist: {
            options: {
              style: 'compressed'
            },
            files: {
              'style.css': 'sass/style.scss'
            }
          }
        }
      });
      grunt.loadNpmTasks('grunt-contrib-sass');
      grunt.registerTask('default', ["sass"]);  // <-- Change to lowercase `s`
    };