Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Plugin to compile Coffee Script in 0.10.0
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
project
src/main/scala
.gitignore
README.md
build.sbt

README.md

XSBT Coffeescript Plugin 1.1

This is a plugin for SBT 0.10.0 (XSBT). It provides tasks and settings for the compilation of CoffeeScript into Javascript. I've packaged this up for my own (and my Company's use) but you can also use Doug Tangren (softprops)'s coffeescripted-sbt repo. He should get credit for creating an installable plugin from an example script I sent to the XSBT mailing list and for updating the example to use the java coffeescript compiler. This is just a follow on (and not an improvement of) his version.

Install

Create a file called `/project/plugins/build.sbt' and add the following lines:

resolvers ++= Seq (
  "zentrope" at "http://zentrope.com/maven"
)

libraryDependencies ++= Seq (
    "com.zentrope" %% "xsbt-coffeescript-plugin" % "1.0"
)

Assumptions

This plugin makes some assumptions about the location of your CoffeeScript source files and the target for your Javascript files:

  • CoffeeScript source files go in /src/main/coffee
  • The resulting Javascript is places in /src/main/www/js

Because this plugin adds the generated Javascript directory to the list of files to be cleaned, please don't store any other files in the <root>/src/main/www/js directory (or its override).

Settings

The following settings can be overridden to change the behavior of the plugin:

coffee-source     ;; location of the coffeescript sources
coffee-target     ;; place to store the resulting javascript files

You can override them in your <root>/build.sbt by something something like:

coffeeSource := (baseDirectory) { (basedir) => new File(basedir, "/src/path/to/js") }

Please note that this Plugin is pretty simple. The sources are assumed to be in a single directory, and the target is assumed to be empty of everything except the generated javascript.

Tasks

Although compiling coffeescript is integrated into the compile and clean tasks built in to SBT, you can invoke these tasks separately:

coffee            ;; compile the coffee sources to the target directory
coffee-clean      ;; remove the generated javascript target directory

These are convenience tasks for when you're developing coffee scripts. When my apps are running, I'll often run the coffee task in a separate terminal over and over until things (after a fashion) work.

Integration

This plugin is integrated into the general XSBT lifecycle as part of its compile and clean infrastructure. When you run:

sbt compile

The functionality behind the coffee task will be invoked. Likewise:

sbt clean

will remove everthing pointed to by the coffee-target setting.

Credits

All due and proper respects to:

Something went wrong with that request. Please try again.