Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Unify sprockets config options

  • Loading branch information...
commit 28fee29e383258c38649e20dc9508188010020c8 1 parent 56a5da8
@josh josh authored
View
2  actionpack/lib/action_controller/railtie.rb
@@ -21,7 +21,7 @@ class Railtie < Rails::Railtie
paths = app.config.paths
options = app.config.action_controller
- options.use_sprockets ||= app.config.asset_pipeline
+ options.use_sprockets ||= app.config.assets.enabled
options.assets_dir ||= paths["public"].first
options.javascripts_dir ||= paths["public/javascripts"].first
options.stylesheets_dir ||= paths["public/stylesheets"].first
View
24 railties/lib/rails/application.rb
@@ -142,23 +142,25 @@ def assets
end
def build_asset_environment
- return unless config.asset_pipeline
+ return unless config.assets.enabled
require 'sprockets'
env = Sprockets::Environment.new(root.to_s)
- env.static_root = root.join("public/assets")
+ env.static_root = root.join("public/#{config.assets.prefix}")
env
end
initializer :add_sprockets_paths do |app|
- if config.asset_pipeline
- [
- "app/javascripts",
- "app/stylesheets",
- "vendor/plugins/*/app/javascripts",
- "vendor/plugins/*/app/stylesheets",
- "vendor/plugins/*/javascripts",
- "vendor/plugins/*/stylesheets"
- ].each do |pattern|
+ if config.assets.enabled
+ paths = [
+ "app/javascripts",
+ "app/stylesheets",
+ "vendor/plugins/*/app/javascripts",
+ "vendor/plugins/*/app/stylesheets",
+ "vendor/plugins/*/javascripts",
+ "vendor/plugins/*/stylesheets"
+ ] + config.assets.paths
+
+ paths.each do |pattern|
Dir[app.root.join(pattern)].each do |dir|
app.assets.paths << dir
end
View
10 railties/lib/rails/application/configuration.rb
@@ -10,7 +10,7 @@ class Configuration < ::Rails::Engine::Configuration
:preload_frameworks, :reload_plugins,
:secret_token, :serve_static_assets, :session_options,
:time_zone, :whiny_nils, :force_ssl,
- :asset_pipeline, :precompile_assets
+ :assets
attr_writer :log_level
@@ -30,8 +30,12 @@ def initialize(*)
@log_level = nil
@middleware = app_middleware
@generators = app_generators
- @asset_pipeline = false
- @precompile_assets = []
+
+ @assets = ActiveSupport::OrderedOptions.new
+ @assets.enabled = false
+ @assets.paths = []
+ @assets.precompile = []
+ @assets.prefix = "/assets"
end
def compiled_asset_path
View
7 railties/lib/rails/application/finisher.rb
@@ -34,15 +34,16 @@ module Finisher
end
initializer :add_sprockets_route do |app|
- if config.asset_pipeline
+ assets = config.assets
+ if assets.enabled
app.routes.append do
- mount app.assets => "/assets"
+ mount app.assets => assets.prefix
end
end
end
initializer :set_sprockets_logger do |app|
- if config.asset_pipeline
+ if config.assets.enabled
app.assets.logger = Rails.logger
end
end

0 comments on commit 28fee29

Please sign in to comment.
Something went wrong with that request. Please try again.