diff --git a/CHANGELOG.md b/CHANGELOG.md index 6366a4d92..b5e8fae63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ **Master** +- Remove custom compressor wrappers when replacing or disabling compression. [Oskar Eichler](https://github.com/OskarEichler) + Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprockets/blob/master/UPGRADING.md # 4.4.1 diff --git a/README.md b/README.md index 958b44cd4..ab1314c40 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ If you want to work on Sprockets or better understand how it works read [How Spr ## Behavior Overview +Assigning `nil` to `js_compressor` or `css_compressor` disables the current compressor, including objects implementing `compress`. Assigning another compressor replaces the previous one. + You can interact with Sprockets primarily through directives and file extensions. This section covers how to use each of these things, and the defaults that ship with Sprockets. Since you are likely using Sprockets through another framework (such as the [Rails asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html)), there will be configuration options you can toggle that will change behavior such as what directories or files get compiled. For that documentation you should see your framework's documentation. diff --git a/lib/sprockets/compressing.rb b/lib/sprockets/compressing.rb index e209f9878..2ed887426 100644 --- a/lib/sprockets/compressing.rb +++ b/lib/sprockets/compressing.rb @@ -47,8 +47,8 @@ def css_compressor # # The compressor object must respond to `compress`. def css_compressor=(compressor) - unregister_bundle_processor 'text/css', @css_compressor if defined? @css_compressor - @css_compressor = nil + unregister_bundle_processor 'text/css', @css_compressor_processor if defined? @css_compressor_processor + @css_compressor_processor = @css_compressor = nil return unless compressor if compressor.is_a?(Symbol) @@ -61,6 +61,7 @@ def css_compressor=(compressor) end register_bundle_processor 'text/css', klass + @css_compressor_processor = klass end # Return JS compressor or nil if none is set @@ -74,8 +75,8 @@ def js_compressor # # The compressor object must respond to `compress`. def js_compressor=(compressor) - unregister_bundle_processor 'application/javascript', @js_compressor if defined? @js_compressor - @js_compressor = nil + unregister_bundle_processor 'application/javascript', @js_compressor_processor if defined? @js_compressor_processor + @js_compressor_processor = @js_compressor = nil return unless compressor if compressor.is_a?(Symbol) @@ -88,6 +89,7 @@ def js_compressor=(compressor) end register_bundle_processor 'application/javascript', klass + @js_compressor_processor = klass end # Public: Checks if Gzip is enabled.