Skip to content

Instantly share code, notes, and snippets.

@atombender
Created August 26, 2013 17:36
Show Gist options
  • Save atombender/6344219 to your computer and use it in GitHub Desktop.
Save atombender/6344219 to your computer and use it in GitHub Desktop.
require 'uglifier'
require 'yaml'
desc 'Create bundle file'
task :bundle do
main_file = File.expand_path('../index.js', __FILE__)
YAML.load(File.open('bundles.yml')).each do |name, opts|
flags = []
if (excludes = [opts['excludes']].flatten)
excludes.each do |exclude|
flags.push "-x #{exclude}"
end
end
out_file = "#{name}.min.js"
File.open(out_file, "w:utf-8") do |f|
f.write Uglifier.compile(
`browserify #{flags.join(' ')} #{main_file}`)
end
puts "Wrote \e[32;1m#{out_file}\e[0m"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment