Created
November 30, 2014 02:29
-
-
Save topher6345/938e5b487a6ea67d8403 to your computer and use it in GitHub Desktop.
Uglify Javascripts in a Jekyll Project.
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 'uglifier' | |
Dir[File.join('_site', '**', '*')].reject { |p| File.directory? p } | |
.each do |file| | |
next unless file[/\.js/] | |
compressed = Uglifier.compile( | |
File.read(file) | |
) | |
File.open(file, 'w') { |newfile| newfile.write(compressed) } | |
puts "#{file} uglified." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment