How to compile Coffeescript, Jade, Stylus in Eclipse

First, here are some links to get you oriented…

Coffeescript - http://jashkenas.github.com/coffee-script/#top

Jade - https://github.com/visionmedia/jade

Stylus - http://learnboost.github.com/stylus/

Each of these is a productivity enhancement. A language to express another language in a more terse manner. One of the main goals of each is DRY (don’t repeat yourself).

The big problem with these is… How do I compile them in my environment with as little hassle as possible. Since, we are looking to become more, not less productive.

Disclaimer: All of these languages (except maybe coffee) are on the bleeding edge. Despite what you’ll read on forums, expect to run into more than your fair share of hiccups. For example, the Jade compiler complains when I have two coffescript: tags. Most likely, I’m doing something wrong, but you’ll probably hit a similar issue.

In eclipse;

1. The easiest path I found was to download node.js and the npm.  The reason for this is, again, just ease… Once you get node and npm installed, you simply run the three respective command line statements to install each module.

> npm install -g coffee-script

> npm install jade

> npm install stylus

2. With these installed, each project contains a /bin directory that holds a program that will allow you access to their compiler through the command line. Because you used npm, there should be a ‘node-modules’ directory somewhere… so go find it… it should contain every module you installed.

3. Open up eclipse. What we want to use is the eclipse builders feature. This allows you to run a program when an action in eclipse happens (ie building a project).

Project -> Properties -> Builders -> New -> Program

4. This should bring up the new builder wizard. The first field ‘location’ you’ll want to browse to where you installed your modules (and specifically the one you want to use).

Be sure to set the next field ‘working directory’ to your project. This will establish a baseline for where the jade command will run, since we don’t want to run it across the whole computer nor in the jade bin directory. Btw, exchange jade with coffee or stylus, we set everything up the same.

Here are my arguments field for each module.

Jade:
./

Coffee:
./ -c

Stylus:
(no arguments for stylus)

5. And that’s it… You can go to the other tabs in the builders wizard to hook into what action you want it to refresh and recompile. So, create a basic *.jade file in your project, write some jade, build the project, and see if your builder ran (or if you have some compiler errors in the eclipse console).

Again, not the best integration, but it’s decent. Until someone writes a proper plug-in. Also, review the command line options for each module to further configure for your workspace.



Published by using 463 words.