Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow app to opt out of precompiling activestorage js assets #43967

Merged
merged 1 commit into from Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions actioncable/lib/action_cable/engine.rb
Expand Up @@ -25,8 +25,8 @@ class Engine < Rails::Engine # :nodoc:

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
Expand Down
7 changes: 5 additions & 2 deletions activestorage/lib/active_storage/engine.rb
Expand Up @@ -30,6 +30,7 @@ class Engine < Rails::Engine # :nodoc:
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
jlestavel marked this conversation as resolved.
Show resolved Hide resolved

config.active_storage.variable_content_types = %w(
image/png
Expand Down Expand Up @@ -167,8 +168,10 @@ class Engine < Rails::Engine # :nodoc:
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

Expand Down
10 changes: 10 additions & 0 deletions guides/source/configuring.md
Expand Up @@ -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:
Expand Down Expand Up @@ -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`
Expand Down