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

Add setting switch to disable assets compilation #244

Merged
merged 1 commit into from
Jan 31, 2023
Merged

Add setting switch to disable assets compilation #244

merged 1 commit into from
Jan 31, 2023

Conversation

n-rodriguez
Copy link
Contributor

Like ActionCable: https://github.com/rails/rails/blob/main/actioncable/lib/action_cable/engine.rb#L27

Useful when using Webpacker to manage static assets

  • My code follows the style guidelines of this project
  • Checks (StandardRB & Prettier-Standard) are passing
  • This is not a documentation update

@marcoroth
Copy link
Member

marcoroth commented Jan 31, 2023

Thanks @n-rodriguez! I thought we had that already, but seems like we don't!

I'm wondering if we should do it like turbo-rails does it?

https://github.com/hotwired/turbo-rails/blob/6db05d69d5f060bd142defe247550b5da5c47228/lib/turbo/engine.rb#L23-L35

Otherwise we should probably add the option to the CableReady::Config class.

@n-rodriguez
Copy link
Contributor Author

I'd prefer to not touch CableReady::Config so let's do it à la Turbo :)

@marcoroth
Copy link
Member

I'd prefer to not touch CableReady::Config

@n-rodriguez Do you have any specific reason for that?

@n-rodriguez
Copy link
Contributor Author

@n-rodriguez Do you have any specific reason for that?

to keep things simple

@n-rodriguez
Copy link
Contributor Author

Actually I don't use the main branch of CableReady, I use 5.0.0.pre9 for both Ruby and JS so I'm not aware of the changes in the APIs.

Maybe this is better :

# config/initializers/cable_ready.rb
CableReady.configure do |config|
  config.precompile_assets = false # new configuration accessor

  config.on_failed_sanity_checks = :ignore

  config.add_operation_name :notify
  config.add_operation_name :progress_bar
end

but it may requires some tests. wdyt?

@marcoroth
Copy link
Member

@n-rodriguez I like the version where we have it in config/initializers/cable_ready.rb 👍🏼

but we can also keep the PRECOMPILE_ASSETS constant so you could also do it the other way if you like.

For ActionText, ActionCable and ActiveStorage it makes sense that they do it that way because the already have their regular a config on application.config

@marcoroth
Copy link
Member

One more thing: Would you mind adding it commented out to:

Then we can merge this, imo 🚀

@n-rodriguez
Copy link
Contributor Author

Then we can merge this, imo rocket

Do you think it's possible to cut a new pre-release for both Ruby and JS?

@marcoroth
Copy link
Member

Yes, pre10 is going out this week!

Copy link
Member

@marcoroth marcoroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @n-rodriguez!

@marcoroth marcoroth merged commit 7616c18 into stimulusreflex:master Jan 31, 2023
@n-rodriguez
Copy link
Contributor Author

Yes, pre10 is going out this week!

Thanks!

@n-rodriguez n-rodriguez deleted the wip/assets branch January 31, 2023 21:20
marcoroth added a commit to stimulusreflex/stimulus_reflex that referenced this pull request Feb 5, 2023
# Type of PR

Enhancement

## Description

This pull request ports over the changes introduced in
stimulusreflex/cable_ready#244

This allows developers to disable the assets pre-compilation step, which
previously happened automatically if the gem was included and sprockets
was installed in the app.

If the project is using esbuild/webpack/vite it's very likely that
there's no need to precompile the StimulusReflex assets in your app.

## Why should this be added

So that developers can turn off the pre-compilation step if they don't
ship the StimulusReflex assets via the Asset pipeline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants