summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2018-06-19 19:43:32 +0200
committerJakub Jirutka <jakub@jirutka.cz>2018-06-19 19:57:10 +0200
commit811b6cf9981d7b778f7643fbbb10c548927560f5 (patch)
tree325cf73e1074e396e48d4a7a274d1072c900456f /Rakefile
parent6b19e7a19013db1c344832f0dc12a143071e4188 (diff)
Set up compilation to JavaScript using Opal
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile19
1 files changed, 19 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
index aa8614e..bc86f92 100644
--- a/Rakefile
+++ b/Rakefile
@@ -22,3 +22,22 @@ begin
rescue LoadError => e
warn "#{e.path} is not available"
end
+
+namespace :build do
+ desc 'Transcompile to JavaScript using Opal'
+ task :js do
+ require 'opal'
+
+ builder = Opal::Builder.new(compiler_options: {
+ dynamic_require_severity: :error,
+ })
+ builder.append_paths 'lib'
+ builder.build 'asciidoctor-interdoc-reftext'
+
+ out_file = 'js/asciidoctor-interdoc-reftext.js'
+
+ mkdir_p(File.dirname(out_file), verbose: false)
+ File.binwrite out_file, builder.to_s
+ File.binwrite "#{out_file}.map", builder.source_map
+ end
+end