Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Allow custom environments #1322

wants to merge 5 commits into from

3 participants


Some usecases require environments like staging or qa

The restriction to just development or production for environment makes it difficult to do certain things.

raphaeleidus Allow custom environments
Some usecases require environments like `staging` or `qa`

I'm ok with this. but we need to do the following:

  1. Update the configuration documentation and provide some help on how to use custom environments.
  2. Change default_output_style and default_line_comments in lib/compass/configuration/defaults.rb to be based on not being the production environment. Ditto for show_full_exception? in lib/compass/compiler.rb.
  3. add tests

@chriseppstein I added a test, some docs and altered the default configurations. Let me know what you think.


Also as a note I was having a bunch of trouble getting the tests to run because of some mocha deprecation.
I had to replace require 'mocha' with require 'mocha/setup' in /test/units/sprites/image_test.rb and I had to comment out the setup method in /test/helpers/test_case.rb entirely.


@chriseppstein could you help me figure out why this test is failing in my fork?


@chriseppstein hey any chance you could help me get this merged in?


@scottdavis could you help me get this ready to be merged?


Looking forward to having this implemented.


I'd like to wait on this until after 1.0 ships.


@chriseppstein do you have a rough timeline on this?


1.0 shipped. Can you rebase this and make sure it's working now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 21, 2013
  1. Allow custom environments

    raphaeleidus authored
    Some usecases require environments like `staging` or `qa`
  2. Update defaults with custom environments in mind

    raphaeleidus authored
  3. Doc the custom environments feature

    raphaeleidus authored
  4. @raphaeleidus

    fix typo

    raphaeleidus authored
  5. @raphaeleidus

    custom environment test

    raphaeleidus authored
This page is out of date. Refresh to see the latest.
6 doc-src/content/help/tutorials/configuration-reference.markdown
@@ -102,7 +102,9 @@ later on.
<td style="vertical-align:top;"><code>environment</code> </td>
<td style="vertical-align:top;">Symbol </td>
<td style="vertical-align:top;">The environment mode.
- Defaults to <code>:production</code>, can also be <code>:development</code>
+ Defaults to <code>:development</code>, traditionally one of <code>:development</code> or <code>:production</code>
+ but any environment string can be provided. Custom environments will use the defaults of the
+ <code>:development</code> environment unless overridden.
@@ -425,4 +427,4 @@ to avoid crashing the watcher in the case where the file has been removed.
self.icon = '/path/to/fail.jpg'
- end
+ end
4 lib/compass/configuration/defaults.rb
@@ -27,7 +27,7 @@ def default_environment
def default_output_style
- if top_level.environment == :development
+ if top_level.environment != :production
@@ -35,7 +35,7 @@ def default_output_style
def default_line_comments
- top_level.environment == :development
+ top_level.environment != :production
def default_color_output
6 lib/compass/exec/project_options_parser.rb
@@ -44,9 +44,9 @@ def set_project_options(opts)
set_dir_or_path(:fonts, fonts_dir)
- opts.on('-e ENV', '--environment ENV', [:development, :production], 'Use sensible defaults for your current environment.',
- ' One of: development (default), production') do |env|
- self.options[:environment] = env
+ opts.on('-e ENV', '--environment ENV', 'Use sensible defaults for your current environment.',
+ ' defaults to development') do |env|
+ self.options[:environment] = env || :development
opts.on('-s STYLE', '--output-style STYLE', [:nested, :expanded, :compact, :compressed], 'Select a CSS output mode.',
11 test/integrations/compass_test.rb
@@ -95,6 +95,17 @@ def test_env_in_production
+ def test_env_in_custom_env
+ within_project('envtest', lambda {|c| c.environment = :staging }) do |proj|
+ each_css_file(proj.css_path) do |css_file|
+ assert_no_errors css_file, 'envtest'
+ end
+ each_sass_file do |sass_file|
+ assert_renders_correctly sass_file, :ignore_charset => true, :environment => "staging"
+ end
+ end
+ end
def test_busted_image_urls
within_project('busted_image_urls') do |proj|
each_css_file(proj.css_path) do |css_file|
Something went wrong with that request. Please try again.