-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.rb
69 lines (58 loc) · 1.47 KB
/
config.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'active_support'
require 'active_support/core_ext'
require 'helpers/content_helpers'
require 'lib/deployment_helpers'
extend DeploymentHelpers
helpers ContentHelpers
#
# Routing
#
# Pretty home path
proxy data.routes.home, config.index_file, ignore: true
# Redirects
activate :s3_redirect do |s3|
s3.bucket = data.deployment.base.host
s3.region = data.deployment.region
s3.after_build = false
end
data.redirects.each do |destination, sources|
sources.each do |source|
redirect source, data.routes[destination]
end
end
# Unique asset URLs
activate :asset_hash
#
# Content
#
activate :autoprefixer do |config|
# Workaround for porada/middleman-autoprefixer#12
config.browsers = ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1']
config.inline = true
end
#
# Deployment
#
# Optimization
configure :build do
activate :gzip, exts: ['', '.js', '.css', '.html']
activate :minify_css, inline: true
activate :minify_html
activate :minify_javascript, inline: true
end
# Static hosting
activate :s3_sync do |s3|
s3.bucket = data.deployment.base.host
s3.region = data.deployment.region
end
content_type data.routes.home, 'text/html'
# Caching
default_caching_policy max_age: 1.year, public: true
activate :cdn do |cdn|
cdn.after_build = false
cdn.cloudflare = { base_urls: [data.deployment.base.to_s],
zone: data.deployment.base.host }
end
after_s3_sync do |files_by_status|
cdn_invalidate files_by_status[:updated]
end