Module: WatchTower::Server::Configurations::Asset

Included in:
App
Defined in:
lib/watch_tower/server/configurations/asset.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/watch_tower/server/configurations/asset.rb', line 13

def self.included(base)
  base.class_eval <<-END, __FILE__, __LINE__ + 1
    # Code taken from
    # https://github.com/stevehodgkiss/sinatra-asset-pipeline/blob/master/app.rb#L11
    set :sprockets, Sprockets::Environment.new(SERVER_PATH)
    set :precompile, [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
    set :assets_prefix, 'assets'
    set :assets_path, ::File.join(SERVER_PATH, 'public', assets_prefix)

    configure do
      # Lib
      sprockets.append_path(::File.join(SERVER_PATH, 'lib', 'assets', 'stylesheets'))
      sprockets.append_path(::File.join(SERVER_PATH, 'lib', 'assets', 'javascripts'))
      sprockets.append_path(::File.join(SERVER_PATH, 'lib', 'assets', 'images'))

      # Vendor
      sprockets.append_path(::File.join(SERVER_PATH, 'vendor', 'assets', 'stylesheets'))
      sprockets.append_path(::File.join(SERVER_PATH, 'vendor', 'assets', 'javascripts'))
      sprockets.append_path(::File.join(SERVER_PATH, 'vendor', 'assets', 'images'))

      # Assets
      sprockets.append_path(::File.join(SERVER_PATH, 'assets', 'stylesheets'))
      sprockets.append_path(::File.join(SERVER_PATH, 'assets', 'javascripts'))
      sprockets.append_path(::File.join(SERVER_PATH, 'assets', 'images'))

      sprockets.context_class.send :extend, Helpers::Asset
    end
  END
end