Skip to content

Commit cac9844

Browse files
jsilvestrirafaelfranca
authored andcommitted
Allow no compression for all environments
1 parent b056b1a commit cac9844

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

lib/sass/rails/railtie.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ class Railtie < ::Rails::Railtie
6868

6969
initializer :setup_compression, group: :all do |app|
7070
unless Rails.env.development?
71-
app.config.assets.css_compressor ||= :sass
71+
# config.assets.css_compressor may be set to nil in non-dev environments.
72+
# otherwise, the default is sass compression.
73+
app.config.assets.css_compressor = :sass unless app.config.assets.has_key?(:css_compressor)
7274
else
7375
# Use expanded output instead of the sass default of :nested unless specified
7476
app.config.sass.style ||= :expanded

test/fixtures/alternate_config_project/config/environments/test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@
3939

4040
# Print deprecation notices to the stderr
4141
config.active_support.deprecation = :stderr
42+
43+
# Decide not to use sass compression
44+
config.assets.css_compressor = nil
4245
end

test/sass_rails_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ class SassRailsTest < Sass::Rails::TestCase
7676
end
7777
end
7878

79+
test 'sass allows compressor override in test mode' do
80+
within_rails_app 'alternate_config_project' do
81+
runner 'test' do
82+
"puts Rails.application.config.assets.css_compressor.nil?"
83+
end
84+
85+
assert_equal 'true', $last_output.chomp
86+
end
87+
end
88+
7989
test 'sass defines compressor by default in production mode' do
8090
within_rails_app 'scss_project' do
8191
runner 'production' do

0 commit comments

Comments
 (0)