Skip to content

Commit

Permalink
Make the API for compression consistent between JS and CSS. By defaul…
Browse files Browse the repository at this point in the history
…t, users just need to say whether they want compression or not, and a default will be chosen by a Railtie. In the case of CSS, this default is already chosen by the sass-rails gem.

Users can still explicitly choose a compressor in their application.rb if they have a preference, but will usually want to let plugins choose defaults in their Railties.
  • Loading branch information
wycats committed Jun 16, 2011
1 parent efa9695 commit f4db3d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 7 additions & 3 deletions actionpack/lib/sprockets/railtie.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def self.using_coffee?


ActiveSupport.on_load(:action_view) do ActiveSupport.on_load(:action_view) do
include ::Sprockets::Helpers::RailsHelper include ::Sprockets::Helpers::RailsHelper

app.assets.context_class.instance_eval do app.assets.context_class.instance_eval do
include ::Sprockets::Helpers::RailsHelper include ::Sprockets::Helpers::RailsHelper
end end
Expand Down Expand Up @@ -63,8 +63,12 @@ def asset_environment(app)


env.logger = Rails.logger env.logger = Rails.logger


env.js_compressor = expand_js_compressor(assets.js_compressor) if assets.compress
env.css_compressor = expand_css_compressor(assets.css_compressor) # temporarily hardcode default JS compressor to uglify. Soon, it will work
# the same as SCSS, where a default plugin sets the default.
env.js_compressor = expand_js_compressor(assets.js_compressor || :uglifier)
env.css_compressor = expand_css_compressor(assets.css_compressor)
end


env env
end end
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
# Compress JavaScripts and CSS # Compress JavaScripts and CSS
config.assets.compress = true config.assets.compress = true


# Specify the default JavaScript compressor
config.assets.js_compressor = :uglifier

# Specifies the header that your server uses for sending files # Specifies the header that your server uses for sending files
# (comment out if your front-end server doesn't support this) # (comment out if your front-end server doesn't support this)
config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
Expand Down

0 comments on commit f4db3d7

Please sign in to comment.