lib/propshaft/railtie.rb in propshaft-0.6.4 vs lib/propshaft/railtie.rb in propshaft-0.7.0

- old
+ new

@@ -1,22 +1,25 @@ require "rails" require "active_support/ordered_options" +require "propshaft/quiet_assets" module Propshaft class Railtie < ::Rails::Railtie config.assets = ActiveSupport::OrderedOptions.new config.assets.paths = [] config.assets.excluded_paths = [] config.assets.version = "1" config.assets.prefix = "/assets" + config.assets.quiet = false config.assets.compilers = [ [ "text/css", Propshaft::Compilers::CssAssetUrls ], [ "text/css", Propshaft::Compilers::SourceMappingUrls ], [ "text/javascript", Propshaft::Compilers::SourceMappingUrls ] ] config.assets.sweep_cache = Rails.env.development? config.assets.server = Rails.env.development? || Rails.env.test? + config.assets.host = nil # Register propshaft initializer to copy the assets path in all the Rails Engines. # This makes possible for us to keep all `assets` config in this Railtie, but still # allow engines to automatically register their own paths. Rails::Engine.initializer "propshaft.append_assets_path", group: :all do |app| @@ -26,10 +29,11 @@ app.config.assets.paths = app.config.assets.paths.without(Array(app.config.assets.excluded_paths).collect(&:to_s)) end config.after_initialize do |app| + config.assets.host = app.config.asset_host config.assets.output_path ||= Pathname.new(File.join(app.config.paths["public"].first, app.config.assets.prefix)) app.assets = Propshaft::Assembly.new(app.config.assets) @@ -52,19 +56,23 @@ initializer "propshaft.logger" do Propshaft.logger = config.assets.logger || Rails.logger end + initializer :quiet_assets do |app| + if app.config.assets.quiet + app.middleware.insert_before ::Rails::Rack::Logger, Propshaft::QuietAssets + end + end + rake_tasks do load "propshaft/railties/assets.rake" end # Compatibility shiming (need to provide log warnings when used) config.assets.precompile = [] config.assets.debug = nil - config.assets.quiet = nil config.assets.compile = nil - config.assets.version = nil config.assets.css_compressor = nil config.assets.js_compressor = nil end end