Kengo's blog

Technical articles about original projects, JVM, Static Analysis and TypeScript.

Rakefile for enchant.js programming

 I found that starting game programming with enchant.js is slow. It has a lot of steps like creating index.html, downloading enchant.js and plugins, downloading images for plugins... it's boring, isn't it?
 最近enchant.jsによる開発の「初速」の遅さが気になっていました。index.html書いて、enchant.js持ってきて、プラグイン持ってきて、プラグインが使う画像を持ってくる、という一連の作業がめんどい。

 We can avoid this problem using jsdo.it, but enchant.js in jsdo.it is too old to use. So I've coded a Rakefile to solve this problem. This Rakefile provides automated downloads and JavaScript optimizations. Plugin isn't supported yet.
 以前ならjsdo.itで解決できましたが、enchant.jsのバージョンが古いので今使うのはちょっと難しい。ということで、必要なファイル一式を揃えるRakefileを書きました。RequireJSによるコードの最適化もできるようになっています。プラグイン未サポート。

 This is the first time for me to use rake. There are 3 reasons why I chose rake: enchant.js uses to build, JavaScript community has a lot of Ruby user (especially server-side), and Maven/Ant (my favorite build system) isn't good solution for this problem. In fact, rake is cool solution. I'll use rake in my product which doesn't based Java.
 rakeを使ったことがないのに選んだ理由としては、enchant.jsがビルドに使っていること、JavaScript界隈(特にサーバサイド)にRuby経験者が多そうなこと、自分が普段使っているMaven/Antでは明らかに不適切と思われたことが挙げられます。実際使ってみたらかなり便利ですねこれ。Java以外のプロダクトで積極採用していきたい。

How to use

wget https://gist.github.com/raw/2181575/23191d759cbfa0d5cd461acccda12c6e6663692b/Rakefile

# creating index.html, enchant.js and other resources
rake

# optimizing your project
rake optimize

# creating zip file
cd optimize
rake package