-
Notifications
You must be signed in to change notification settings - Fork 82
Grunt Tasks
You can manually run the grunt tasks on which lineman is built with the lineman grunt
command. (It just delegates through to grunt
.) You can also run any additional grunt tasks that you've added yourself.
$ lineman grunt <taskname>
Lineman can easily be extended to do extra grunt-work for your application above-and-beyond the built-in grunt tasks. You may add tasks to your project in several ways:
- Custom tasks you've written yourself:
- add it to the
tasks/
directory. Lineman will automatically load any tasks found here.
- add it to the
- npm-packaged tasks:
- add it to your
package.json
as a dependency - add it to the
loadNpmTasks
key inconfig/application.js
using the task's npm module name (normally used ingrunt.loadNpmTasks(<module_name>)
) - run
npm install
- add it to your
- npm install --save or --save-dev
- use --save for runtime dependencies and --save-dev for development dependencies
-
npm install <grunt-pkg> --save
ornpm install <grunt-pkg> --save-dev
- add or add to the loadNpmTasks key in
config/application.js'
loadNPMTasks: ['grunt-pkg'],` - add or add to the prependTasks or appendTasks as below.
Once they're loaded, you can manually run the task from the command line using lineman grunt
. But you're probably more interested in having these tasks run alongside the other tasks as part of lineman run
and/or lineman build
...
You can add any task to the lineman run/build processes by adding it to the appropriate array under the prependTasks
and appendTasks
objects in config/application.js
:
prependTasks: {
common: ["A"],
dev: ["B"],
dist: ["C"]
},
appendTasks: {
common: ["D"],
dev: ["E"],
dist: ["F"]
}
In the above example, tasks "A" & "D" would run during both lineman run
and lineman build
. Meanwhile, "B" & "E" would run only during lineman run
, while "C" & "F" would only run during lineman build
.
Tasks specified under prependTasks
will be run before Lineman's built-in tasks for the corresponding phase (dev or dist), while tasks specified under appendTasks
will run immediately afterward. For reference, check out Lineman's default configuration.
If you need to remove a task that's built into Lineman, you can use the removeTasks
configuration. For example, if you wanted to disable Lineman's CoffeeScript task, you could do this:
removeTasks: {
common: ["coffee"]
}
To use grunt-codo (Codo is a javascript documentation tool) in a lineman project.
# From the top dir of your project.
$ npm install grunt-codo --save-dev
# config/application.coffee
module.exports = (lineman)->
loadNpmTasks: ['grunt-codo']
codo:
options:
name: "Awesome Lib"
title: "Awesome Lib Documentation"
undocumented: yes
src: ["app/js"]
appendTasks:
common: ["codo"]
If you need more fine-grained control, you can use custom JavaScript in your application config file to edit the appropriate array directly; here's an example of removing a task from the Ember.js template. Note: This example is out of date and is more easily accomplished with removeTasks
as described above. The Ember.js template has been appropriately updated as well.
# grab lineman's config object
config = require(process.env['LINEMAN_MAIN']).config
# remove the 'handlebars' task
config.application.appTasks.common = _(config.application.appTasks.common).reject (n) -> n == "handlebars"
# extend as usual
module.exports = config.extend 'application',
server:
...