In this recipe, we'll make use of the contrib-coffee (0.11.0)
plugin to compile CoffeeScript source files to JavaScript.
In this example, we'll work with the basic project structure we created in the Installing Grunt on a project recipe in Chapter 1, Getting Started with Grunt. Be sure to refer to it if you are not yet familiar with its contents.
The following steps will take us through creating a simple CoffeeScript source file and compiling it to JavaScript:
We'll start by installing the package that contains the
contrib-coffee
plugin, as per the instructions provided in the Installing a plugin recipe in Chapter 1, Getting Started with Grunt.Let's create a simple CoffeeScript file called
main.coffee
in our project directory with the following contents:logic = (message) -> console.log(message) message = 'Functionality!' logic(message)
Now, we can add the following
coffee
task to our configuration, which will compile the...