Skip to content

Commit

Permalink
Allow to work even if SourceMapServer is missing
Browse files Browse the repository at this point in the history
Newer Opal::Sprockets serves source maps inline and has removed the 
server.
  • Loading branch information
elia committed Sep 7, 2018
1 parent 4342686 commit 37769dc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/opal/rails/engine.rb
Expand Up @@ -34,14 +34,16 @@ class Engine < ::Rails::Engine
Opal::Config.send(key, value) if Opal::Config.respond_to? key
end

app.routes.prepend do
if Opal::Config.source_map_enabled && config.assets.compile && config.assets.debug
maps_prefix = '/__OPAL_SOURCE_MAPS__'
maps_app = Opal::SourceMapServer.new(app.assets, maps_prefix)
if defined?(Opa::SourceMapServer)
app.routes.prepend do
if Opal::Config.source_map_enabled && config.assets.compile && config.assets.debug
maps_prefix = '/__OPAL_SOURCE_MAPS__'
maps_app = Opal::SourceMapServer.new(app.assets, maps_prefix)

::Opal::Sprockets::SourceMapHeaderPatch.inject!(maps_prefix)
::Opal::Sprockets::SourceMapHeaderPatch.inject!(maps_prefix)

mount maps_app => maps_prefix
mount maps_app => maps_prefix
end
end
end
end
Expand Down

0 comments on commit 37769dc

Please sign in to comment.