-
Notifications
You must be signed in to change notification settings - Fork 759
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
Fix running on sprockets-rails master #322
Conversation
vipulnsward
commented
Jul 18, 2015
- Assets version and register_engine have been moved from app.assets to app.config.assets on sprockets
- Added a check to make sure to use proper asset object when calling version, register_engine, etc
…to app.config.assets on sprockets - Added a check to make sure to use proper asset object when calling version, register_engine, etc
Sprockets.register_engine '.jsx', React::JSX::Template | ||
else | ||
app.assets.register_engine '.jsx', React::JSX::Template | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(app.assets || Sprockets).register_engine '.jsx', React::JSX::Template```
Maybe this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually its harder to read that way and make the intent clear why we are doing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also like the idea of removing that duplication, maybe:
sprockets_env = app.assets || Sprockets # Sprockets 3.x expects this in a different place
sprockets_env.register_engine(".jsx", React::JSX::Template)
IMO less duplication = easier to maintain in the future!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Hi @rmosolgo, can you take a look at this when you time. This causes issues when used with newest version of sprockets. |
if app.assets.nil? | ||
app.config.assets.version = [app.config.assets.version, "react-#{asset_variant.react_build}",].compact.join('-') | ||
else | ||
app.assets.version = [app.assets.version, "react-#{asset_variant.react_build}",].compact.join('-') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could also be DRYer, eg
sprockets_env = app.assets || app.config.assets # sprockets-rails 3.x attaches this at a different config
sprockets_env.version = [ ... ].compact.join("-")
@rmosolgo done. |
🎊 nice! maybe we should add an Appraisal for Rails 5 beta or something next. |
Fix running on sprockets-rails master
@rmosolgo, @vipulnsward Just a heads up, I've been trying to make it work with Rails 5 and atm it immediately fails on .register_engine line. Looks like sprockets removed engines completely. So with sprockets 4.0 the initializer should probably look something like:
|
🙈 Sprockets is unstable atm with all the refactoring. I will work on On Wednesday, September 2, 2015, rovr notifications@github.com wrote:
Vipul A.M. |
@vipulnsward Thanks! I understand, I just thought I might save you some debugging time in the future. So if sprockets choose to go with the current interface: The object that you pass to the So if you do
Then inside of React::JSX you must have a method like:
Looks like that's all it takes to make it work with the current sprockets master branch. |
Bumping into this now. if this helps @rovr's fork works for me with current Rails master - thanks! |