Created
January 19, 2016 14:31
-
-
Save felinebabies/e1938d7a24e4620f8b46 to your computer and use it in GitHub Desktop.
Opalでrubyスクリプトをjavascriptにコンパイルする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rake/clean' | |
| SRCDIR = './src' | |
| DESTDIR = './dest' | |
| SRCS = FileList[SRCDIR + "/**/*.rb"] | |
| JSS = SRCS.ext('js') | |
| directory DESTDIR | |
| # 出力先パスに書き換え | |
| JSS.gsub!(SRCDIR, DESTDIR) | |
| puts JSS | |
| CLEAN.include(JSS) | |
| CLOBBER.include('opal_js') | |
| task :default => [DESTDIR, 'opal_js'] | |
| desc 'Opalでrubyスクリプトをjavascriptにコンパイルする' | |
| file 'opal_js' => JSS | |
| # ディレクトリの変更を含む場合、正規表現によるルール指定が必要 | |
| # http://qiita.com/takkkun/items/c588c96b9ecf38021312 | |
| rule %r{^\./dest/.+\.js} => '%{^\./dest,./src}X.rb' do |t| | |
| sh "bundle exec opal --compile #{t.source.gsub(DESTDIR, SRCDIR)} > #{t.name}" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment