Skip to content

Commit

Permalink
Updating Rakefile to compress files in the proper order
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Wallace committed Jul 9, 2010
1 parent 1114c60 commit 4553b0f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ajax-solr.min.js
28 changes: 22 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,30 @@ desc 'Compress all JavaScript files'
task :compress do
output_file = ENV.include?('output') ? ENV['output'] : 'ajax-solr.min.js'

core = [
'Core',
'AbstractManager',
'ParameterStore',
'AbstractWidget',
'AbstractFacetWidget'
]

dirs = [
'core',
'helpers',
'managers',
'widgets'
]

File.open(output_file, 'w') do |output|
compressor = YUI::JavaScriptCompressor.new(:munge => true)
files = Dir['**/*.js']
files.each do |file|
next if file == output_file
puts "Compressing #{file}"
input = ''
File.open(file, 'r') { |f| input = f.read }

files = core.map{ |name| "core/#{name}.js" } + dirs.map{ |dir| Dir["#{dir}/**/*.js"] }.flatten
files.uniq!

files.each do |file_name|
puts "Compressing #{file_name}"
input = File.open(file_name, 'r') { |f| f.read }
output.write(compressor.compress(input))
end
end
Expand Down

0 comments on commit 4553b0f

Please sign in to comment.