Skip to content

Commit c189f27

Browse files
author
Robert Mosolgo
committed
Merge pull request #322 from vipulnsward/sprockets-3-compat
Fix running on sprockets-rails master
2 parents 4dffbf9 + 9133f80 commit c189f27

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/react/rails/engine.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ module React
22
module Rails
33
class Engine < ::Rails::Engine
44
initializer "react_rails.setup_engine", :group => :all do |app|
5-
app.assets.register_engine '.jsx', React::JSX::Template
5+
sprockets_env = app.assets || Sprockets # Sprockets 3.x expects this in a different place
6+
sprockets_env.register_engine(".jsx", React::JSX::Template)
67
end
78
end
89
end

lib/react/rails/railtie.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ class Railtie < ::Rails::Railtie
3838
addons: app.config.react.addons,
3939
})
4040

41-
app.assets.version = [
42-
app.assets.version,
43-
"react-#{asset_variant.react_build}",
44-
].compact.join('-')
41+
sprockets_env = app.assets || app.config.assets # sprockets-rails 3.x attaches this at a different config
42+
sprockets_env.version = [sprockets_env.version, "react-#{asset_variant.react_build}",].compact.join('-')
43+
4544
end
4645

4746
config.before_initialize do |app|

0 commit comments

Comments
 (0)