-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.rb
55 lines (44 loc) · 991 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require "sinatra"
require 'sass/plugin/rack'
require 'sinatra/assetpack'
require "sinatra/reloader"
set :root, File.dirname(__FILE__)
set :sass, { :load_paths => [ "./assets/css" ] }
register Sinatra::AssetPack
configure :development do
register Sinatra::Reloader
end
configure :production do
set :static_cache_control, [:public, :max_age => 300]
before do
cache_control :public, :max_age => 300
end
end
assets {
# css_compression :sass
js_compression :simple
serve '/js', from: 'assets/js'
serve '/css', from: 'assets/css'
serve '/img', from: 'assets/img'
serve '/fonts', from: 'assets/fonts'
js :app, '/js/app.js', [
'/js/vendor/jquery.js',
'/js/vendor/*.js',
'/js/app/*.js'
]
css :app, [
'/css/app.css'
]
}
helpers do
def production?
ENV['RACK_ENV'] == 'production'
end
ASSET_HOST = production? ? 'http://d12qi0sd8r0cmx.cloudfront.net' : ""
def asset path
ASSET_HOST + path
end
end
get "/" do
erb :index
end