Rakefile in opal-js_wrap-three-0.1.3 vs Rakefile in opal-js_wrap-three-0.1.4
- old
+ new
@@ -20,5 +20,36 @@
sh "npx babel #{js} -o lib-opal/js_wrap/three/#{js.split("/jsm/").last}"
end
end
task default: %i[build_js build_js_examples]
+
+task :build_gh_pages do
+ require 'fileutils'
+
+ output_dir = __dir__+"/gh-pages/examples/"
+ FileUtils.mkdir_p output_dir
+
+ Dir['examples/*'].each do |example_path|
+ example = File.basename(example_path)
+
+ output_example_dir = output_dir+"/"+example
+ FileUtils.mkdir_p output_example_dir
+
+ Dir.chdir(example_path) do
+ Bundler.with_unbundled_env do
+ `bundle install`
+ `bundle exec opal -qopal/js_wrap/three -c example.rb > #{output_example_dir}/app.js`
+ end
+ File.write("#{output_example_dir}/index.html", <<~HTML)
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <style> body { margin: 0; } </style>
+ <script src="app.js"></script>
+ </head>
+ <body></body>
+ </html>
+ HTML
+ end
+ end
+end
\ No newline at end of file