Axiol
Axiol

Reputation: 5962

Tasks and sub-tasks not found

I just started using Grunt and I already may have a problem. So, here is what my Gruntfile.js looks like :

module.exports = function (grunt) {
  grunt.initConfig({

    // Ability to access the package.json informations
    pkg: grunt.file.readJSON('package.json'),

    // SASS compilation
    sass: {
      dist: {
        options: {
          style: 'compressed'
        },
        expand: true,
        cwd: './sass/',
        src: 'main.scss',
        dest: './css/',
        ext: '.css'
      },
      dev: {
        options: {
          style: 'expanded',
          debugInfo: true,
          lineNumbers: true
        },
        expand: true,
        cwd: './sass/',
        src: 'main.scss',
        dest: './css/',
        ext: '.css'
      }
    }

  });
};

And when I run grunt sass:dev, it always returns me Warning: Task "sass:dev" not found. Use --force to continue.

As I'm starting with it, I took a look at the doc and can't find where I may have gone wrong... And yes, dependencies are correctly installed.

Upvotes: 1

Views: 2071

Answers (1)

Ben
Ben

Reputation: 10156

You need to make sure the task is registered, after the initConfig section.

module.exports = function (grunt) {
  grunt.initConfig({
    // ...
  });
  grunt.loadNpmTasks('grunt-contrib-sass');
};

Upvotes: 5

Related Questions