Integrating CoffeeScript with Eclipse?

前端 未结 3 1416
夕颜
夕颜 2021-01-30 22:17

Is there a way to integrate CoffeeScript and Eclipse, so that when I write CoffeeScript in one window the other will show the compiled code as Javascript?

I\'ll wait for

3条回答
  •  离开以前
    2021-01-30 23:14

    I've done it with a builder and a small shell script in my project. Every time I save a .coffee file, it compiles all my scripts. Works great.

    Right click on your project. Select properties near the bottom of the menu.

    • Builders
    • New...
    • Location: ${workspace_loc:/ProjectName/coffee-compile.sh}
    • Working Directory: ${workspace_loc:/ProjectName}
    • Refresh: Specify the folder where your generated .js files live. This allows you to keep the .js file open as well and it'll auto update when things re-compile.
    • Build Options: Specify the folder where your .coffee files live.

    ProjectName/coffee-compile.sh:

    #!/bin/bash
    
    if [ ! -d ./target/coffee ]; then
        mkdir -p ./target/coffee
    fi
    
    echo "Compiling coffee script files..."
    /usr/bin/coffee --output ./target/coffee --compile ./coffee
    
    echo "Done..."
    

    The builder definition is saved as part of your project. It is in the .settings folder. That way, other developers can check out your project as well and have everything already set up.

    Update: For code formatting and coloring, I ended up installing the latest beta of Aptana into Eclipse.

    Update2: I've stopped using Eclipse in favor of Intellij. The editors and built in support for compiling code are wonderful. I highly suggest you try it out.

提交回复
热议问题