From 811b6cf9981d7b778f7643fbbb10c548927560f5 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Tue, 19 Jun 2018 19:43:32 +0200 Subject: Set up compilation to JavaScript using Opal --- Rakefile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'Rakefile') 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 -- cgit v1.2.3