Created
December 7, 2011 07:10
-
-
Save jrmoran/1441817 to your computer and use it in GitHub Desktop.
minify js and css files
This file contains hidden or 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
# These files will be minified ... | |
javascripts: | |
- build/js/ga.js | |
- build/js/jquery-1.7.1.js | |
- build/js/portfolio.js | |
styles: | |
- build/style/screen_v3.css | |
# And combined into single files | |
outputjs: build/js/client.js | |
outputcss: build/style/style.css |
This file contains hidden or 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
require 'yaml' | |
require 'yui/compressor' | |
desc 'minify all the things' | |
task :min do | |
assets = YAML.load_file 'assets.yml' | |
outjs = File.new assets['outputjs'], 'w' | |
outcss = File.new assets['outputcss'], 'w' | |
js = assets[ 'javascripts' ].collect{ |f| IO.read("#{f}") } | |
css = assets[ 'styles' ].collect{ |f| IO.read("#{f}") } | |
js_compressor = YUI::JavaScriptCompressor.new :munge => true | |
css_compressor = YUI::CssCompressor.new | |
outjs.write js_compressor.compress( js.join ' ' ) | |
outcss.write css_compressor.compress( css.join ' ' ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment