提交 88cb8905 编写于 作者: T tomhuda 提交者: wycats

Change compressor API so that plugins can register default compressors for...

Change compressor API so that plugins can register default compressors for their stylesheet or JS engines and still allow the user to turn off compression
上级 4b86e7ba
...@@ -28,7 +28,8 @@ def self.using_scss? ...@@ -28,7 +28,8 @@ def self.using_scss?
# We need to configure this after initialization to ensure we collect # We need to configure this after initialization to ensure we collect
# paths from all engines. This hook is invoked exactly before routes # paths from all engines. This hook is invoked exactly before routes
# are compiled. # are compiled, and so that other Railties have an opportunity to
# register compressors.
config.after_initialize do |app| config.after_initialize do |app|
assets = app.config.assets assets = app.config.assets
next unless assets.enabled next unless assets.enabled
...@@ -61,8 +62,8 @@ def asset_environment(app) ...@@ -61,8 +62,8 @@ def asset_environment(app)
env.static_root = File.join(app.root.join("public"), assets.prefix) env.static_root = File.join(app.root.join("public"), assets.prefix)
env.paths.concat assets.paths env.paths.concat assets.paths
env.logger = Rails.logger env.logger = Rails.logger
env.js_compressor = expand_js_compressor(assets.js_compressor) env.js_compressor = expand_js_compressor(assets.js_compressor) if app.assets.compress
env.css_compressor = expand_css_compressor(assets.css_compressor) env.css_compressor = expand_css_compressor(assets.css_compressor) if app.assets.compress
env env
end end
......
...@@ -21,4 +21,7 @@ ...@@ -21,4 +21,7 @@
# Only use best-standards-support built into browsers # Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin config.action_dispatch.best_standards_support = :builtin
# Do not compress assets
config.assets.compress = false
end end
...@@ -11,9 +11,11 @@ ...@@ -11,9 +11,11 @@
# Disable Rails's static asset server (Apache or nginx will already do this) # Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false config.serve_static_assets = false
# Compress both stylesheets and JavaScripts # Compress JavaScripts and CSS
config.assets.compress = true
# Specify the default JavaScript compressor
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier
config.assets.css_compressor = :scss
# 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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册