Plugins You can find out about all the publicly available Grails plugins.

CoffeeScript Resources

  • Authors: Edvinas Bartkus
2 votes
compile "org.grails.plugins:coffeescript-resources:0.3.8"

 Documentation  Issues


Plugin that automatically compiles CoffeeScript to JavaScript and works with the resources plugin.


grails install-plugin coffeescript-resources


This is a grails plugin that enables the easy inclusion of CoffeeScript (+)( in your Grails web application. It requires the well established resources plugin.


As the author, Jeremy Ashkenas (+)(, says himself "CoffeeScript is a little language that compiles to JavaScript". CoffeeScript is an attempt to make writing JavaScript easier, more elegant, and more efficient.

The standard CoffeeScript compiler runs on NodeJs. This plugin is basically a bridge (via Mozilla's Rhino engine (+)( to a browser compatible version of the compiler released by Jeremy Ashkenas. It uses CoffeeScript version 1.2.0.


To add coffee script resources to your grails project
  • Install the plugin
  • Actually add your CoffeeScript files to your project. I placed mine adjacent to the js folder in cs.
  • Reference your CoffeeScript files in your ApplicationResources file (or where ever you are defining your resources).
js {
  resource url: 'js/app.js'
coffee {
  resource url: 'cs/'
  resource url: 'cs/'

Files should be located:

- web-app
 - js
    - app/.js
 - cs

The above example will create a resource you can include in pages or have another resource depend on. The CoffeeScript files are converted to JavaScript, and included like any of your JavaScript files. The default disposition for your CoffeeScript follows the JavaScript default: "defer" - that is they will appear at the end of your page.


Every resource module is compressed to bundle. By default .coffee files are not added to any bundle. In order to have it in the bundle you must explicitly declare bundle attribute for the resource line or defaultBundle for the module.
modules {
    example1 {
      defaultBundle 'example1'
      resource url: 'cs/'

exmaple2 { resource url: 'cs/', bundle: 'example1' } }