gruntjs / grunt-contrib-sass

Compile Sass to CSS.
http://gruntjs.com/
MIT License
848 stars 141 forks source link

passing variables to sass #199

Closed loominade closed 9 years ago

loominade commented 9 years ago

I'd like to add a variable to the job. like the viewmode in this one

grunt.initConfig({
  sass: {
    wide: {
      options: {
        style: 'expanded',
        variables: {
          viewmode: 'wide',        
        }
      },
      files: {
        'wide.css': 'main.sass'
      }
    }
    narrow: {
      options: {
        style: 'expanded',
        variables: {
          viewmode: 'narrow',        
        }
      },
      files: {
        'narrow.css': 'main.sass'
      }
    }
  }
});

So i can work with the $viewmodevariable in sass:

body:before
  @if $viewmode == 'wide'
    content: 'you are in the wide viewmode'
  @if $viewmode == 'narrow'
    content: 'you are in the narrow viewmode'

can I do this somehow?

sindresorhus commented 9 years ago

You can easily prepend something using another task. Eg. https://github.com/sindresorhus/grunt-header

Any feature requests will have to be implemented in Sass first. This task only wraps it.