|
1 | 1 | #Example2 Goals
|
2 |
| -This example will compile a single Less file into one CSS file and the other task will take multiple Less files and compile them into one file. In this example you'll see there are two different registered Grunt tasks for you to use. |
| 2 | +This example will compile a single LESS file into one CSS file and the other task will take multiple LESS files and compile them into one file. In this example you'll see there are two different configurations for one Grunt task. |
3 | 3 |
|
4 | 4 | #Example2 Explained
|
5 |
| -In this example I setup 2 different Grunt tasks under the Less compiler. |
6 |
| -The first task is: |
| 5 | +In this example I setup 2 different Grunt configurations under the `less` task. |
| 6 | +The first configuration is: |
7 | 7 |
|
8 | 8 | onlyFile1: {
|
9 | 9 | files: [
|
10 | 10 | {"dist/css/file1.css": "src/less/file1.less"}
|
11 | 11 | ]
|
12 | 12 | },
|
13 | 13 |
|
14 |
| -This task targets only the Less file called file1 and compiles it into file1.css. This is a pretty simple example of 1 to 1 compiling for Less files. |
| 14 | +This configuration targets only the LESS file called `file1.less` and compiles it into `file1.css`. This is a pretty simple example of 1 to 1 compiling for LESS files. |
15 | 15 |
|
16 |
| -The next Less task is one that compiles multiple files: |
| 16 | +The next LESS configuration is one that compiles multiple files: |
17 | 17 |
|
18 | 18 | allFiles: {
|
19 | 19 | files: [
|
20 | 20 | {"dist/css/common.css": "src/less/*.less"}
|
21 | 21 | ]
|
22 | 22 | }
|
23 | 23 |
|
24 |
| -Any less files in the src/less/ folder will get compiled into 1 CSS file called dist/css/common.css. Grunt uses this 1 to many syntax for a lot of different tasks, so once you get use to it you can use it all over the place. If you were to aggregate CSS/JS files you'd use the same sytnax as the one above. |
| 24 | +Any less files in the `src/less/` folder will get compiled into 1 CSS file called `dist/css/common.css`. Grunt uses this 1 to many syntax for a lot of different tasks, so once you get use to it you can use it all over the place. If you were to aggregate CSS/JS files you'd use the same sytnax as the one above. |
25 | 25 |
|
26 | 26 | One difference from Example1 that you'll notice is how I registerd the Grunt tasks.
|
27 | 27 |
|
28 | 28 | grunt.registerTask("onlyfileone", ["less:onlyFile1"]);
|
29 | 29 | grunt.registerTask("prod", ["less:allFiles"]);
|
30 | 30 |
|
31 |
| -In both tasks there is the word `less`, a colon, and the sub-tasks (`onlyFile1`, or `allfiles`). This is where I think Grunt becomes really awesome. What Grunt is allowing me to do is point directly at a sub-task instead of the task as a whole. So if I registered: `grunt.registerTask("prod", ["less"]);` it would run all sub-tasks inside of the `less` task no matter how many there are. Using the : helps tell Grunt which tasks to specifically run; you can chain these together if you need to: |
| 31 | +In both tasks there is the word `less`, a colon, and the sub-tasks (`onlyFile1`, or `allfiles`). This is where I think Grunt becomes really awesome. What Grunt is allowing me to do is point directly at a specific configuration instead of the task as a whole. So if I registered: `grunt.registerTask("prod", ["less"]);` it would run all configurations inside of the `less` task no matter how many there are. Using the `:` helps tell Grunt which tasks to specifically run. This is awesome because you can chain these together if you need to: |
32 | 32 |
|
33 | 33 | grunt.registerTask("prod", ["less:allFiles", "less:someOtherTask", "less:anotherTask"]);
|
34 | 34 |
|
35 | 35 | #To run this Example
|
36 |
| -`grunt onlyfileone` will compile only one Less file |
| 36 | +`grunt onlyfileone` will compile only one LESS file |
37 | 37 |
|
38 |
| -`grunt prod` will compile all of the Less files |
| 38 | +`grunt prod` will compile all of the LESS files |
39 | 39 |
|
40 | 40 | #Additional Notes
|
41 |
| -For more information on the [grunt-contrib-less make sure to visit their github page.](https://github.com/gruntjs/grunt-contrib-less) |
| 41 | +For more information visit the following links: |
| 42 | + |
| 43 | +* [grunt-contrib-less make sure to visit their github page.](https://github.com/gruntjs/grunt-contrib-less) |
| 44 | + |
| 45 | +* [configuring tasks](http://gruntjs.com/configuring-tasks) |
0 commit comments