Created
May 4, 2013 04:29
-
-
Save iwarner/5516184 to your computer and use it in GitHub Desktop.
Middleman - GZIP Content - 3.0.x branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Create GZIP Content Helper | |
### Add this snippet to the config.rb | |
### Add the activate :gzip to the build section | |
helpers do | |
def gzip_css_on_build(key, media = "screen") | |
o = stylesheet_link_tag(key, { :media => media }) | |
o.sub!(".css", ".css.gz") if build? | |
o | |
end | |
def gzip_js_on_build(key) | |
o = javascript_include_tag(key) | |
o.sub!(".js", ".js.gz") if build? | |
o | |
end | |
end | |
### Build-specific configuration | |
configure :build do | |
# GZIP Files | |
activate :gzip | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-# In your layout include the stylesheets with | |
= gzip_css_on_build "site", "all" | |
-# And the Javascript with | |
= gzip_js_on_build :all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment