1 | # grunt-contrib-coffee [](http://travis-ci.org/gruntjs/grunt-contrib-coffee) |
---|
2 | |
---|
3 | > Compile CoffeeScript files to JavaScript. |
---|
4 | |
---|
5 | |
---|
6 | |
---|
7 | ## Getting Started |
---|
8 | This plugin requires Grunt `~0.4.0` |
---|
9 | |
---|
10 | If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: |
---|
11 | |
---|
12 | ```shell |
---|
13 | npm install grunt-contrib-coffee --save-dev |
---|
14 | ``` |
---|
15 | |
---|
16 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: |
---|
17 | |
---|
18 | ```js |
---|
19 | grunt.loadNpmTasks('grunt-contrib-coffee'); |
---|
20 | ``` |
---|
21 | |
---|
22 | *This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that [you upgrade](http://gruntjs.com/upgrading-from-0.3-to-0.4), but in case you can't please use [v0.3.2](https://github.com/gruntjs/grunt-contrib-coffee/tree/grunt-0.3-stable).* |
---|
23 | |
---|
24 | |
---|
25 | ## Coffee task |
---|
26 | _Run this task with the `grunt coffee` command._ |
---|
27 | |
---|
28 | Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide. |
---|
29 | ### Options |
---|
30 | |
---|
31 | #### separator |
---|
32 | Type: `String` |
---|
33 | Default: linefeed |
---|
34 | |
---|
35 | Concatenated files will be joined on this string. |
---|
36 | |
---|
37 | #### bare |
---|
38 | Type: `boolean` |
---|
39 | |
---|
40 | Compile the JavaScript without the top-level function safety wrapper. |
---|
41 | |
---|
42 | #### join |
---|
43 | Type: `boolean` |
---|
44 | Default: `false` |
---|
45 | |
---|
46 | When compiling multiple .coffee files into a single .js file, concatenate first. |
---|
47 | |
---|
48 | #### sourceMap |
---|
49 | Type: `boolean` |
---|
50 | Default: `false` |
---|
51 | |
---|
52 | Compile JavaScript and create a .map file linking it to the CoffeeScript source. When compiling multiple .coffee files to a single .js file, concatenation occurs as though the 'join' option is enabled. The concatenated CoffeeScript is written into the output directory, and becomes the target for source mapping. |
---|
53 | ### Usage Examples |
---|
54 | |
---|
55 | ```js |
---|
56 | coffee: { |
---|
57 | compile: { |
---|
58 | files: { |
---|
59 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile |
---|
60 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile and concat into single file |
---|
61 | } |
---|
62 | }, |
---|
63 | |
---|
64 | compileBare: { |
---|
65 | options: { |
---|
66 | bare: true |
---|
67 | }, |
---|
68 | files: { |
---|
69 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile |
---|
70 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile and concat into single file |
---|
71 | } |
---|
72 | }, |
---|
73 | |
---|
74 | compileJoined: { |
---|
75 | options: { |
---|
76 | join: true |
---|
77 | }, |
---|
78 | files: { |
---|
79 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile, identical output to join = false |
---|
80 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // concat then compile into single file |
---|
81 | } |
---|
82 | }, |
---|
83 | |
---|
84 | compileWithMaps: { |
---|
85 | options: { |
---|
86 | sourceMap: true |
---|
87 | }, |
---|
88 | files: { |
---|
89 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile |
---|
90 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // concat then compile into single file |
---|
91 | } |
---|
92 | }, |
---|
93 | |
---|
94 | glob_to_multiple: { |
---|
95 | expand: true, |
---|
96 | flatten: true, |
---|
97 | cwd: 'path/to', |
---|
98 | src: ['*.coffee'], |
---|
99 | dest: 'path/to/dest/', |
---|
100 | ext: '.js' |
---|
101 | } |
---|
102 | } |
---|
103 | ``` |
---|
104 | |
---|
105 | For more examples on how to use the `expand` API to manipulate the default dynamic path construction in the `glob_to_multiple` examples, see "Building the files object dynamically" in the grunt wiki entry [Configuring Tasks](http://gruntjs.com/configuring-tasks). |
---|
106 | |
---|
107 | ## Release History |
---|
108 | |
---|
109 | * 2013-04-19âââv0.7.0âââPlace Sourcemaps at bottom of file Change extension for Sourcemaps from .maps to .js.map |
---|
110 | * 2013-04-18âââv0.6.7âââImproved error reporting |
---|
111 | * 2013-04-08âââv0.6.6âââFix regression with single-file compilation. |
---|
112 | * 2013-04-05âââv0.6.5âââImproved error reporting |
---|
113 | * 2013-03-22âââv0.6.4âââSourcemap support |
---|
114 | * 2013-03-19âââv0.6.3âââIncrease error logging verbosity. |
---|
115 | * 2013-03-18âââv0.6.2âââBump to CoffeeScript 1.6.2 |
---|
116 | * 2013-03-18âââv0.6.1âââSupport `join` option |
---|
117 | * 2013-03-06âââv0.6.0âââBump to CoffeeScript 1.6 Support literate CoffeeScript extension coffee.md |
---|
118 | * 2013-02-25âââv0.5.0âââBump to CoffeeScript 1.5 Support literate CoffeeScript (.litcoffee) |
---|
119 | * 2013-02-15âââv0.4.0âââFirst official release for Grunt 0.4.0. |
---|
120 | * 2013-01-23âââv0.4.0rc7âââUpdating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions. Bump coffeescript dependency to 1.4. |
---|
121 | * 2013-01-09âââv0.4.0rc5âââUpdating to work with grunt v0.4.0rc5. Switching to this.filesSrc api. |
---|
122 | * 2012-12-15âââv0.4.0aâââConversion to grunt v0.4 conventions. Remove experimental destination wildcards. |
---|
123 | * 2012-10-12âââv0.3.2âââRename grunt-contrib-lib dep to grunt-lib-contrib. |
---|
124 | * 2012-09-25âââv0.3.1âââDon't fail when there are no files. |
---|
125 | * 2012-09-24âââv0.3.0âââGlobal options depreciated. |
---|
126 | * 2012-09-10âââv0.2.0âââRefactored from grunt-contrib into individual repo. |
---|
127 | |
---|
128 | --- |
---|
129 | |
---|
130 | Task submitted by [Eric Woroshow](http://ericw.ca/) |
---|
131 | |
---|
132 | *This file was generated on Fri Apr 19 2013 09:49:08.* |
---|