Skip to content

Commit

Permalink
Allow no compression for all environments
Browse files Browse the repository at this point in the history
  • Loading branch information
jsilvestri committed Jul 14, 2015
1 parent 8e68c5f commit 9a4f24f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/sass/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class Railtie < ::Rails::Railtie

initializer :setup_compression, group: :all do |app|
unless Rails.env.development?
app.config.assets.css_compressor ||= :sass
# config.assets.css_compressor may be set to nil in non-dev environments.
# otherwise, the default is sass compression.
app.config.assets.css_compressor = :sass unless app.config.assets.has_key?(:css_compressor)
else
# Use expanded output instead of the sass default of :nested unless specified
app.config.sass.style ||= :expanded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@

# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr

# Decide not to use sass compression
config.assets.css_compressor = nil
end
10 changes: 10 additions & 0 deletions test/sass_rails_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ class SassRailsTest < Sass::Rails::TestCase
end
end

test 'sass allows compressor override in test mode' do
within_rails_app 'alternate_config_project' do
runner 'test' do
"puts Rails.application.config.assets.css_compressor.nil?"
end

assert_equal 'true', $last_output.chomp
end
end

test 'sass defines compressor by default in production mode' do
within_rails_app 'scss_project' do
runner 'production' do
Expand Down

0 comments on commit 9a4f24f

Please sign in to comment.