Skip to content

Commit

Permalink
Merge pull request #338 from jsilvestri/nil-compression
Browse files Browse the repository at this point in the history
Allow no compression for all environments
  • Loading branch information
rafaelfranca committed Sep 3, 2015
2 parents 805cb17 + 9a4f24f commit 3616c29
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 @@ -72,7 +72,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 3616c29

Please sign in to comment.