Skip to content

Commit 43eb2e3

Browse files
committed
fix(Railtie) don't mount to Sprockets if Sprockets env is not present
1 parent fa88f38 commit 43eb2e3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/react/rails/railtie.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,15 @@ class Railtie < ::Rails::Railtie
9898
end
9999

100100
initializer "react_rails.setup_engine", :group => :all do |app|
101-
if app.config.react.sprockets_strategy == false
102-
# pass, sprockets opt-out
103-
else
104-
# Sprockets 3.x expects this in a different place
105-
sprockets_env = app.assets || defined?(Sprockets) && Sprockets
101+
# Sprockets 3.x expects this in a different place
102+
sprockets_env = app.assets || defined?(Sprockets) && Sprockets
106103

104+
if app.config.react.sprockets_strategy == false
105+
# pass, Sprockets opt-out
106+
elsif sprockets_env.present?
107107
React::JSX::SprocketsStrategy.attach_with_strategy(sprockets_env, app.config.react.sprockets_strategy)
108+
else
109+
# pass, Sprockets is not preset
108110
end
109111
end
110112
end

0 commit comments

Comments
 (0)