A Rakefile to build CoffeeScript projects
15 Jul 2012
Update: I’ve since overhauled this project to be an npm package called Arabica. You should check it out.
Using the script is very simple, but there are a few dependencies that must be resolved beforehand. An installation of Ruby and RubyGems is required. The Gemfile is only present for convenience - the script should work just fine if happen to already have the gems installed or want to install them manually, but you'll want the Rakefile in your project's root. If you're installing using the Gemfile, grab bundler if necessary with
gem install bundler and finally
bundle install to install the uglifier and listen gems. Once you've set up all dependencies, put your project filenames (in the desired order) in the
FILENAMES array, and customize the
DIST_PATH variables to your needs. You can call
rake build manually to build the application, or just watch the source files with
rake watch which will compile automatically anytime you save a change.
I tend to keep my editor and terminal on separate workspaces, so I added a Growl notification that alerts you if a compile attempt failed - this is totally optional and can be removed if you prefer. Finally, the
rake clean task removes all compiled files (including distribution files) if you ever need to clean up your directory.
I've already run into the issue trying to include non-CoffeeScript files (such as vendor JS libraries), but it's entirely possible with a small hack and I can update to post that if anyone would like. As always, I welcome ideas or suggestions for improvement!Tweet