Source maps are available (on current stable release, v0.6.x) even without explicit support from Sprockets in a sort of hackish way.
As such even if they generally work fine there are some limitations and edge case issues.
Currently on master
branch sourcemaps are work-in-progress and probably will integrate with the upcoming Sprockets 4 that has integrated support for them.
source_map_enabled
flagTo enable sourcemaps in the Sprockets processor you need to turn on the relative flag:
Opal::Processor.source_map_enabled = true # default
The sourcemaps only work with Sprockets in debug mode because they are generated just for single files.
Rails has debug mode already enabled in development environment with the following line from config/environments/development.rb
:
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
opal-rails
also enables sourcemaps in development so with the standard setup you ready to go.
You can add Opal::Server
as in the official example: sinatra/config.ru.
Opal::Server
implements sourcemaps and can be used alone or with Rack::Cascade
in conjunction with other apps.
Opal::Environment
is a bit lower level and doesn't support source maps by itself.