Search code examples
compass-sass

Can I configure Compass to write into separate directories based on the environment or output_style?


Using Compass, is it possible to define two directories to compile to based upon the environment or output_style variables in the config.rb?

For example, I'd like to have two directories:

  • /css/
  • /css/dev/

When Compass' configured environment is set to :production, it will compile style into /css/. However, when the environment is set to :development, it would compile style into /css/dev/.

Likewise, would it be possible to the same thing based on the output_style option? For example, if it is :expanded it would compile to the production directory and when it is :compressed it would compile to the development directory.


Solution

  • This should be possible using conditional statements:

    if output_style == :expanded
      environment = :development
      css_dir = 'css/dev'
      sass_options = { :debug_info => true }
    else
      environment = :production
      css_dir = 'css'
    end