md2essay/Rakefile
2015-04-07 02:35:17 -05:00

21 lines
542 B
Ruby

require 'uglifier'
task default: %w[build]
task :build do
puts "browserifying"
puts system("browserify -t coffeeify browser.app.coffee > js/markdowntomla.js")
puts "building minified self-contained index.html"
html = File.read('template.html')
bundled = html.split("\n").map{|line|
if line =~ /\<script.*src=\"(.*)\"/
path = $1
js = Uglifier.compile(File.read(path))
"<script type='text/javascript'>#{js}</script>"
else
line
end
}
File.open('built/index.html', 'w'){|f| f.puts bundled}
end