UNPKG

6.63 kBMarkdownView Raw
1# grunt-contrib-coffee v0.13.0 [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-contrib-coffee.svg?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#### joinExt
61Type: `String`
62Default: '.src.coffee'
63
64Resulting extension when joining multiple CoffeeScript files.
65
66### Usage Examples
67
68```js
69coffee: {
70 compile: {
71 files: {
72 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile
73 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile and concat into single file
74 }
75 },
76
77 compileBare: {
78 options: {
79 bare: true
80 },
81 files: {
82 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile
83 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile and concat into single file
84 }
85 },
86
87 compileJoined: {
88 options: {
89 join: true
90 },
91 files: {
92 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile, identical output to join = false
93 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // concat then compile into single file
94 }
95 },
96
97 compileWithMaps: {
98 options: {
99 sourceMap: true
100 },
101 files: {
102 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile
103 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // concat then compile into single file
104 }
105 },
106
107 compileWithMapsDir: {
108 options: {
109 sourceMap: true,
110 sourceMapDir: 'path/to/maps/' // source map files will be created here
111 },
112 files: {
113 'path/to/result.js': 'path/to/source.coffee'
114 }
115 },
116
117 glob_to_multiple: {
118 expand: true,
119 flatten: true,
120 cwd: 'path/to',
121 src: ['*.coffee'],
122 dest: 'path/to/dest/',
123 ext: '.js'
124 }
125
126}
127```
128
129For 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](http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically)" in the grunt wiki entry [Configuring Tasks](http://gruntjs.com/configuring-tasks).
130
131
132## Release History
133
134 * 2015-02-20   v0.13.0   Updates to CoffeeScript 1.9.1.
135 * 2014-10-04   v0.12.0   Fixes litcoffee sourcemaps. Updates to CoffeeScript 1.8.0.
136 * 2014-08-15   v0.11.1   Fixes summary logging.
137 * 2014-08-06   v0.11.0   Adds summary containing number of files created. Move file creation logging to grunt.verbose. Updates Chalk to 0.5.
138 * 2014-02-07   v0.10.0   SourceMappingURL calculated correctly
139 * 2014-01-29   v0.9.0   Source mapping fixes. Update coffee-script to 1.7.0 Use lodash directly instead of deprecated grunt.util._
140 * 2014-01-17   v0.8.2   Force coffeescript 1.6.3 Use new sourceMappingUrl syntax.
141 * 2014-01-17   v0.8.1   Fix sourcemap regression.
142 * 2013-12-24   v0.8.0   Support sourceMapDir
143 * 2013-04-19   v0.7.0   Place Sourcemaps at bottom of file Change extension for Sourcemaps from .maps to .js.map
144 * 2013-04-18   v0.6.7   Improved error reporting
145 * 2013-04-08   v0.6.6   Fix regression with single-file compilation.
146 * 2013-04-05   v0.6.5   Improved error reporting
147 * 2013-03-22   v0.6.4   Sourcemap support
148 * 2013-03-19   v0.6.3   Increase error logging verbosity.
149 * 2013-03-18   v0.6.2   Bump to CoffeeScript 1.6.2
150 * 2013-03-18   v0.6.1   Support `join` option
151 * 2013-03-06   v0.6.0   Bump to CoffeeScript 1.6 Support literate CoffeeScript extension coffee.md
152 * 2013-02-25   v0.5.0   Bump to CoffeeScript 1.5 Support literate CoffeeScript (.litcoffee)
153 * 2013-02-15   v0.4.0   First official release for Grunt 0.4.0.
154 * 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.
155 * 2013-01-09   v0.4.0rc5   Updating to work with grunt v0.4.0rc5. Switching to this.filesSrc api.
156 * 2012-12-15   v0.4.0a   Conversion to grunt v0.4 conventions. Remove experimental destination wildcards.
157 * 2012-10-12   v0.3.2   Rename grunt-contrib-lib dep to grunt-lib-contrib.
158 * 2012-09-25   v0.3.1   Don't fail when there are no files.
159 * 2012-09-24   v0.3.0   Global options depreciated.
160 * 2012-09-10   v0.2.0   Refactored from grunt-contrib into individual repo.
161
162---
163
164Task submitted by [Eric Woroshow](http://ericw.ca/)
165
166*This file was generated on Fri Feb 20 2015 15:16:40.*