Skip to content
Jason Karns edited this page Jun 5, 2013 · 10 revisions

Running 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>

Adding Grunt Tasks

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 two ways:

  • Custom tasks you've written yourself:
    1. add it to the tasks/ directory. Lineman will automatically load any tasks found here.
  • NPM-packaged tasks:
    1. add it to your package.json as a dependency
    2. add it to loadNpmTasks in config/application.js using the task's NPM module name normally used in grunt.loadNpmTasks('___')
    3. run npm install

Once they're loaded, you can manually run the task from the command line using lineman grunt but you're probably more interested in adding these tasks to run along with the other tasks in lineman run and/or lineman build...

Hooking Into Lineman's run/build processes

You can add any task to the lineman run and/or build process 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 way will be run before Lineman's built-in tasks for the corresponding phase, while tasks specified under appendTasks will run immediately afterward. For reference, check out Lineman's default configuration.

Modifying Lineman's run/build process directly

If you need more fine-grained control—say you want to replace or remove a default task—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.

Clone this wiki locally