-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
43 lines (29 loc) · 884 Bytes
/
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
# frozen_string_literal: true
require 'rubygems'
require 'bundler'
Bundler.require(:default)
BUILD_FILES = %w[hyper-router hyperstack-compiler hyperstack opal].freeze
def compile_js(filename)
puts "Compiling #{filename}.js..."
File.binwrite("./dist/#{filename}.js", Opal::Builder.build(filename).to_s)
puts '...done!'
end
def minify_js(filename)
puts "Minifying #{filename}.js..."
js_file = "./dist/#{filename}.js"
js_min_file = "./dist/#{filename}.min.js"
File.open(js_min_file, 'w').write(Uglifier.new(harmony: true).compile(File.read(js_file)))
puts '...done!'
end
desc 'Compile and minify hyperstack libs'
task :compile do
Opal.append_path 'lib'
# Cleanup previous builds
FileUtils.rm_rf('dist')
FileUtils.mkdir('dist')
BUILD_FILES.each do |filename|
compile_js(filename)
minify_js(filename)
end
end
task default: %i[compile]