-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
48 lines (41 loc) · 1.02 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'bundler'
Bundler.require
Bundler::GemHelper.install_tasks
require 'opal/rspec/rake_task'
Opal::RSpec::RakeTask.new(:default) do |s|
s.index_path = 'spec/html/index.html.erb'
end
desc "Build build/opal-pixi.js"
task :dist do
require 'fileutils'
FileUtils.mkdir_p 'build'
src = Opal::Builder.build('opal-pixi')
#min = uglify src
#gzp = gzip min
File.open('build/opal-pixi.js', 'w+') do |out|
out << src
end
#puts "development: #{src.size}, minified: #{min.size}, gzipped: #{gzp.size}"
end
# Used for uglifying source to minify
def uglify(str)
IO.popen('uglifyjs', 'r+') do |i|
i.puts str
i.close_write
return i.read
end
rescue Errno::ENOENT
$stderr.puts '"uglifyjs" command not found (install with: "npm install -g uglify-js")'
nil
end
# Gzip code to check file size
def gzip(str)
IO.popen('gzip -f', 'r+') do |i|
i.puts str
i.close_write
return i.read
end
rescue Errno::ENOENT
$stderr.puts '"gzip" command not found, it is required to produce the .gz version'
nil
end