sassgruntjsgrunt-contrib-sass

How I can write few tasks in grunt-contrib-sass?


I have some like this in my gruntfile.js:

        sass: {
            app: {
                files: {
                 '<%= meta.cssDist %>style.css': '<%= meta.cssSrc %>style.scss'
                }
            },
            options: {
                style: 'nested'
            }
    },
grunt.registerTask('default', ['sass']);

But this is only one task. How I can combine two or more tasks? As I know in some grunt modules you can combine multiple tasks like this:

            sass: {
              dev: {
                 app: {
                    files: {
                      '<%= meta.cssDist %>style.css': '<%= meta.cssSrc %>style.scss'
                    }
                 },
                 options: {
                    style: 'nested'
                 }
              },

              production: {
                 app: {
                    files: {
                      '<%= meta.cssDist %>style.css': '<%= meta.cssSrc %>style.scss'
                    }
                 },
                 options: {
                    style: 'compressed',
                    sourcemap: 'none'
                 }
              }
    },
    // and then register tasks
    grunt.registerTask('dev', ['sass:dev']);
    grunt.registerTask('prod', ['sass:production']);

But this doesn't work, GruntJs didn't show mistake and didn't compile sass. What is wrong with this?


Solution

  • I find my mistake, it would run this tasks in such way:

    sass: {
    dev: {
        files: {
            '<%= meta.cssDist %>style.css': '<%= meta.cssSrc %>style.scss'
        },
        options: {
            style: 'nested'
        }
    },
    production: {
        files: {
            '<%= meta.cssDist %>style.css': '<%= meta.cssSrc %>style.scss'
        }
        options: {
            style: 'compressed',
            sourcemap: 'none'
        }
    }
    }
    grunt.registerTask('dev', ['sass:dev']);
    grunt.registerTask('prod', ['sass:production']);