Michael Mallett
Michael Mallett

Reputation: 744

Sass style options ignored in Gruntfile

I have the following gruntfile, that compiles fine, however it appears to be ignore the style option and only use the default 'nested' style. I've tried compressed, expanded and compact and they all come out exactly the same.

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    sass: {
      dist: {
        files: {
          'css/style.css' : 'scss/main.scss'
        },
        options: {
          sourceMap: true,
          style: 'expanded'
        }
      }
    },
    sass_globbing: {
      your_target: {
        files: {
          'scss/_base.scss': 'scss/base/**/*.scss',
          'scss/_layout.scss': 'scss/layout/**/*.scss',
          'scss/_components.scss': 'scss/components/**/*.scss',
          'scss/_theme.scss': 'scss/theme/**/*.scss'
        },
        options: {
          useSingleQuoates: false
        }
      }
    },
    autoprefixer: {
      dist: {
        options : {
          browsers: ['last 2 version','ie 8','ie 9','android 4']
        },
        files: {
          'css/style.css' : 'css/style.css'
        }
      }
    },
    watch: {
      options: {
        livereload: true
      },
      css: {
        files: '**/*.scss',
        tasks: ['sass_globbing','sass','autoprefixer']
      }
    }
  });
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-sass-globbing');
  grunt.loadNpmTasks('grunt-autoprefixer');
  grunt.registerTask('default',['watch']);
}

I'm using:

I've tried adding changes to the scss files, deleting the stylesheet, generating a totally new file with a different name, running grunt sass --force and it still generates the same file (and it is generating the file). I've also tried overriding the style in grunt with grunt sass --style compact --force, and still no joy.

What am I doing wrong?

Upvotes: 0

Views: 104

Answers (1)

chrisg86
chrisg86

Reputation: 11857

According to the documentation at https://github.com/sindresorhus/grunt-sass#usage, the options key goes one level higher (Move it out of dist):

grunt.initConfig({
    sass: {
        options: {
            sourceMap: true,
            style: 'compressed'
        },
        dist: {
            ...
       }
   }
}

Hope this helps!

Upvotes: 1

Related Questions