Sha256: 2a4400386f48d385e836353bec8634dd558cfd118535c7e9d2311913875a996b

Contents?: true

Size: 742 Bytes

Versions: 8

Compression:

Stored size: 742 Bytes

Contents

require 'opal'
require 'sinatra'

opal = Opal::Server.new {|s|
  s.append_path 'app'
  s.main = 'application'
}

sprockets   = opal.sprockets
maps_prefix = '/__OPAL_SOURCE_MAPS__'
maps_app    = Opal::SourceMapServer.new(sprockets, maps_prefix)

# Monkeypatch sourcemap header support into sprockets
::Opal::Sprockets::SourceMapHeaderPatch.inject!(maps_prefix)

map maps_prefix do
  run maps_app
end

map '/assets' do
  run sprockets
end

get '/' do
  opal_boot_code = Opal::Processor.load_asset_code(sprockets, 'application')

  <<-HTML
    <!doctype html>
    <html>
      <head>
        <script src="/assets/application.js"></script>
        <script>#{opal_boot_code}</script>
      </head>
    </html>
  HTML
end

run Sinatra::Application

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
opal-0.8.1 examples/sinatra/config.ru
opal-0.8.1.rc1 examples/sinatra/config.ru
opal-wedge-0.9.0.dev examples/sinatra/config.ru
opal-0.8.0 examples/sinatra/config.ru
opal-0.8.0.rc3 examples/sinatra/config.ru
opal-0.8.0.rc2 examples/sinatra/config.ru
opal-0.8.0.rc1 examples/sinatra/config.ru
opal-0.8.0.beta1 examples/sinatra/config.ru