Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minify JS and CSS in production

  • Loading branch information...
commit 170829f2ab62003de692415c375e466b976ad774 1 parent 4263e8f
@peteog authored
Showing with 14 additions and 4 deletions.
  1. +9 −2 lib/sinatra/simple_assets.rb
  2. +5 −2 sinatra-simple-assets.gemspec
View
11 lib/sinatra/simple_assets.rb
@@ -41,11 +41,16 @@ def hashed_path
end
def hash
- @hash ||= Digest::SHA1.hexdigest combined
+ @hash ||= Digest::SHA1.hexdigest content
end
def content
- combined
+ case @type
+ when :js
+ @content ||= Uglifier.new.compress combined
+ when :css
+ @content ||= CSSMin.minify combined
+ end
end
def combined
@@ -119,6 +124,8 @@ def serve_content(bundle, type)
content_type type
content
+
+ #TODO set cache headers
end
end
end
View
7 sinatra-simple-assets.gemspec
@@ -8,13 +8,16 @@ Gem::Specification.new do |s|
s.authors = ["Pete O'Grady"]
s.email = ['pete@peteogrady.com']
s.homepage = ""
- s.summary = %q{TODO: Write a gem summary}
- s.description = %q{TODO: Write a gem description}
+ s.summary = %q{Asset minification and bundling for Sinatra}
+ s.description = %q{Asset minification and bundling for Sinatra}
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ['lib']
+ s.add_dependency 'cssmin', '1.0.2'
s.add_dependency 'sinatra', '~> 1.3.0'
+ s.add_dependency 'therubyracer-heroku', '0.8.1.pre3'
+ s.add_dependency 'uglifier', '1.1.0'
end
Please sign in to comment.
Something went wrong with that request. Please try again.