diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2018-06-19 19:43:32 +0200 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2018-06-19 19:57:10 +0200 |
commit | 811b6cf9981d7b778f7643fbbb10c548927560f5 (patch) | |
tree | 325cf73e1074e396e48d4a7a274d1072c900456f /Rakefile | |
parent | 6b19e7a19013db1c344832f0dc12a143071e4188 (diff) |
Set up compilation to JavaScript using Opal
Diffstat (limited to 'Rakefile')
-rw-r--r-- | Rakefile | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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 |