Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow no compression for all environments #338

Merged
merged 1 commit into from
Sep 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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