UNPKG

5.97 kBMarkdownView Raw
1# grunt-contrib-coffee v0.9.0 [![Build Status](https://travis-ci.org/gruntjs/grunt-contrib-coffee.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-coffee)
2
3> Compile CoffeeScript files to JavaScript.
4
5
6
7## Getting Started
8This plugin requires Grunt `~0.4.0`
9
10If 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
13npm install grunt-contrib-coffee --save-dev
14```
15
16Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
17
18```js
19grunt.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
28Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.
29### Options
30
31#### separator
32Type: `String`
33Default: linefeed
34
35Concatenated files will be joined on this string.
36
37#### bare
38Type: `boolean`
39
40Compile the JavaScript without the top-level function safety wrapper.
41
42#### join
43Type: `boolean`
44Default: `false`
45
46When compiling multiple .coffee files into a single .js file, concatenate first.
47
48#### sourceMap
49Type: `boolean`
50Default: `false`
51
52Compile 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
53
54#### sourceMapDir
55Type: `String`
56Default: (same path as your compiled js files)
57
58Generated source map files will be created here.
59
60### Usage Examples
61
62```js
63coffee: {
64 compile: {
65 files: {
66 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile
67 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile and concat into single file
68 }
69 },
70
71 compileBare: {
72 options: {
73 bare: true
74 },
75 files: {
76 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile
77 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile and concat into single file
78 }
79 },
80
81 compileJoined: {
82 options: {
83 join: true
84 },
85 files: {
86 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile, identical output to join = false
87 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // concat then compile into single file
88 }
89 },
90
91 compileWithMaps: {
92 options: {
93 sourceMap: true
94 },
95 files: {
96 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile
97 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // concat then compile into single file
98 }
99 },
100
101 compileWithMapsDir: {
102 options: {
103 sourceMap: true,
104 sourceMapDir: 'path/to/maps/' // source map files will be created here
105 },
106 files: {
107 'path/to/result.js': 'path/to/source.coffee'
108 }
109 }
110
111 glob_to_multiple: {
112 expand: true,
113 flatten: true,
114 cwd: 'path/to',
115 src: ['*.coffee'],
116 dest: 'path/to/dest/',
117 ext: '.js'
118 },
119
120}
121```
122
123For 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).
124
125
126## Release History
127
128 * 2014-01-29   v0.9.0   Source mapping fixes. Update coffee-script to 1.7.0 Use lodash directly instead of deprecated grunt.util._
129 * 2014-01-17   v0.8.2   Force coffeescript 1.6.3 Use new sourceMappingUrl syntax.
130 * 2014-01-17   v0.8.1   Fix sourcemap regression.
131 * 2013-12-24   v0.8.0   Support sourceMapDir
132 * 2013-04-19   v0.7.0   Place Sourcemaps at bottom of file Change extension for Sourcemaps from .maps to .js.map
133 * 2013-04-18   v0.6.7   Improved error reporting
134 * 2013-04-08   v0.6.6   Fix regression with single-file compilation.
135 * 2013-04-05   v0.6.5   Improved error reporting
136 * 2013-03-22   v0.6.4   Sourcemap support
137 * 2013-03-19   v0.6.3   Increase error logging verbosity.
138 * 2013-03-18   v0.6.2   Bump to CoffeeScript 1.6.2
139 * 2013-03-18   v0.6.1   Support `join` option
140 * 2013-03-06   v0.6.0   Bump to CoffeeScript 1.6 Support literate CoffeeScript extension coffee.md
141 * 2013-02-25   v0.5.0   Bump to CoffeeScript 1.5 Support literate CoffeeScript (.litcoffee)
142 * 2013-02-15   v0.4.0   First official release for Grunt 0.4.0.
143 * 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.
144 * 2013-01-09   v0.4.0rc5   Updating to work with grunt v0.4.0rc5. Switching to this.filesSrc api.
145 * 2012-12-15   v0.4.0a   Conversion to grunt v0.4 conventions. Remove experimental destination wildcards.
146 * 2012-10-12   v0.3.2   Rename grunt-contrib-lib dep to grunt-lib-contrib.
147 * 2012-09-25   v0.3.1   Don't fail when there are no files.
148 * 2012-09-24   v0.3.0   Global options depreciated.
149 * 2012-09-10   v0.2.0   Refactored from grunt-contrib into individual repo.
150
151---
152
153Task submitted by [Eric Woroshow](http://ericw.ca/)
154
155*This file was generated on Wed Jan 29 2014 09:57:09.*