grunt-pretasks
Version:
Pre tasks for Grunt
57 lines (47 loc) • 1.8 kB
Markdown
# grunt-pretasks
>Pre Tasks for Grunt
[](https://npmjs.org/package/grunt-pretasks "View this project on NPM")
[](https://npmjs.org/package/grunt-pretasks "View this project on NPM")
## Getting Started
This plugin requires Grunt `>=0.4.5`
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:
```shell
npm install grunt-pretasks --save-dev
```
Once the plugin has been installed, it needs to be enabled inside your Gruntfile with this line of JavaScript:
**note: you must place this line before loading any task**
```js
require('grunt-pretasks')(grunt);
```
## Usage
To run pre tasks just add a `preTasks: [task...]` property to the options object of the task that you wish to run the pre task(s) before.
The following example will run `['cleanArtifacts', 'compile', 'compileTests']`
before any call to `karma` or `karma:chrome` or `karma:firefox` etc...
```js
karma: {
options: {
preTasks: ['cleanArtifacts', 'compile', 'compileTests'],
configFile: './test/karma/config.js'
},
chrome: {
browsers: ['Chrome'],
singleRun: false
},
firefox: {
browsers: ['Firefox'],
singleRun: false
},
ie: {
browsers: ['IE'],
singleRun: false
},
singleRunFirefox: {
browsers: ['Firefox'],
singleRun: true
},
all: {
browsers: ['Chrome', 'Firefox', 'IE']
}
};
```