diff --git a/actioncable/lib/action_cable/engine.rb b/actioncable/lib/action_cable/engine.rb index 9d95b28d22..e369068ade 100644 --- a/actioncable/lib/action_cable/engine.rb +++ b/actioncable/lib/action_cable/engine.rb @@ -25,8 +25,8 @@ module ActionCable initializer "action_cable.asset" do config.after_initialize do |app| - if Rails.application.config.respond_to?(:assets) && app.config.action_cable.precompile_assets - Rails.application.config.assets.precompile += %w( actioncable.js actioncable.esm.js ) + if app.config.respond_to?(:assets) && app.config.action_cable.precompile_assets + app.config.assets.precompile += %w( actioncable.js actioncable.esm.js ) end end end diff --git a/activestorage/lib/active_storage/engine.rb b/activestorage/lib/active_storage/engine.rb index 81306ff3ba..53495011ab 100644 --- a/activestorage/lib/active_storage/engine.rb +++ b/activestorage/lib/active_storage/engine.rb @@ -30,6 +30,7 @@ module ActiveStorage config.active_storage.analyzers = [ ActiveStorage::Analyzer::ImageAnalyzer::Vips, ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick, ActiveStorage::Analyzer::VideoAnalyzer, ActiveStorage::Analyzer::AudioAnalyzer ] config.active_storage.paths = ActiveSupport::OrderedOptions.new config.active_storage.queues = ActiveSupport::InheritableOptions.new + config.active_storage.precompile_assets = true config.active_storage.variable_content_types = %w( image/png @@ -167,8 +168,10 @@ module ActiveStorage end initializer "active_storage.asset" do - if Rails.application.config.respond_to?(:assets) - Rails.application.config.assets.precompile += %w( activestorage activestorage.esm ) + config.after_initialize do |app| + if app.config.respond_to?(:assets) && app.config.active_storage.precompile_assets + app.config.assets.precompile += %w( activestorage activestorage.esm ) + end end end diff --git a/guides/source/configuring.md b/guides/source/configuring.md index afe9c21293..59d2bb06f2 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -1972,6 +1972,11 @@ Cable as part of your normal Rails server. You can find more detailed configuration options in the [Action Cable Overview](action_cable_overview.html#configuration). +#### `config.action_cable.precompile_assets` + +Determines whether the Action Cable assets should be added to the asset pipeline precompilation. It +has no effect if Sprockets is not used. The default value is `true`. + ### Configuring Active Storage `config.active_storage` provides the following configuration options: @@ -2192,6 +2197,11 @@ The default value depends on the `config.load_defaults` target version: | (original) | `false` | | 7.0 | `true` | +#### `config.active_storage.precompile_assets` + +Determines whether the Active Storage assets should be added to the asset pipeline precompilation. It +has no effect if Sprockets is not used. The default value is `true`. + ### Configuring Action Text #### `config.action_text.attachment_tag_name`