Skip to content

Commit 071605f

Browse files
committed
updating README.md files
1 parent 428f771 commit 071605f

File tree

5 files changed

+59
-21
lines changed

5 files changed

+59
-21
lines changed

Example1/README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ somewhere, but don't want to type that long path each time.
2525
The src section can be a single file, array of files, or match a pattern.
2626
Remember, because I used cwd above the current path is: `src/`
2727
The `css/**` piece tells Grunt to not only look in the root of the css folder,
28-
also copy the contents of all of the sub folders.
28+
also copy the contents of all of the sub folders. This configuration uses the [dynamic file objects feature](http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically) and the [global pattern syntax](http://gruntjs.com/configuring-tasks#globbing-patterns).
2929

3030
`src: ["js/*", "css/**"],`
3131

@@ -47,4 +47,10 @@ To "run" a Grunt task you use a simple syntax of the word grunt and the task nam
4747
`grunt prod` will move the CSS and JS assets to the `/dist` folder.
4848

4949
#Additional Notes
50-
For more information on the [grunt-contrib-copy make sure to visit their github page.](https://github.com/gruntjs/grunt-contrib-copy)
50+
For more information visit the following links:
51+
52+
* [grunt-contrib-copy make sure to visit their github page.](https://github.com/gruntjs/grunt-contrib-copy)
53+
54+
* [dynamic file objects feature](http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically)
55+
56+
* [global pattern syntax](http://gruntjs.com/configuring-tasks#globbing-patterns)

Example2/README.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,45 @@
11
#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.
33

44
#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:
77

88
onlyFile1: {
99
files: [
1010
{"dist/css/file1.css": "src/less/file1.less"}
1111
]
1212
},
1313

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.
1515

16-
The next Less task is one that compiles multiple files:
16+
The next LESS configuration is one that compiles multiple files:
1717

1818
allFiles: {
1919
files: [
2020
{"dist/css/common.css": "src/less/*.less"}
2121
]
2222
}
2323

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.
2525

2626
One difference from Example1 that you'll notice is how I registerd the Grunt tasks.
2727

2828
grunt.registerTask("onlyfileone", ["less:onlyFile1"]);
2929
grunt.registerTask("prod", ["less:allFiles"]);
3030

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:
3232

3333
grunt.registerTask("prod", ["less:allFiles", "less:someOtherTask", "less:anotherTask"]);
3434

3535
#To run this Example
36-
`grunt onlyfileone` will compile only one Less file
36+
`grunt onlyfileone` will compile only one LESS file
3737

38-
`grunt prod` will compile all of the Less files
38+
`grunt prod` will compile all of the LESS files
3939

4040
#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)

Example3/README.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This example will show you how you'd setup a minified and non-minified version of css and js. Technically this is only a minor increase from Example2, but I think it was important enough to split out so certain parts can be clear.
33

44
#Example3 Explained
5-
Debugging minified javascript is a pain, so its always nice to do development against an unminified code. In this example we'll be taking multiple Less files and compiling them into one CSS file, and then minifying them. We'll also be taking multiple JS files, concatenating them together, and then minifying them.
5+
Debugging minified javascript is a pain, so its always nice to do development against an unminified code. In this example we'll be taking multiple LESS files and compiling them into one CSS file, and then minifying them. We'll also be taking multiple JS files, concatenating them together, and then minifying them.
66

77
The first task is the one that does the JS file concatenation:
88

@@ -13,9 +13,9 @@ The first task is the one that does the JS file concatenation:
1313
}
1414
},
1515

16-
You might normally use this to concatanate CSS files if you were not already using a Less compiler. However, since I am using a Less compiler I'll just use it to concatenate all of the JS files.
16+
You might normally use this to concatanate CSS files if you were not already using a LESS compiler. However, since I am using a LESS compiler I'll just use it to concatenate all of the JS files.
1717

18-
The Less task you already saw in Example2.
18+
The LESS task you already saw in Example2.
1919

2020
The javascript uglify task is the next one:
2121

@@ -30,7 +30,7 @@ The uglify task does basically what any other javascript uglifier/minifier does.
3030

3131

3232

33-
I setup this Grunt file so when `grunt prod` is run an unminified version of the file will be created, and another minified verison of the file will be made. This way I can keep track of both version as I needed. The grunt task will first run the JS concatenator so that all the javascript files are turned into `dist/js/all-js.js`. Next the Less files will be compiled into `dist/css/common.css` much like Example2. However, the next two steps take those finished files, minify them, and save a copy off with thte word "min" in it. So `all-js.js` becomes `all-js.min.js`, and `common.css` becomes `common.min.css`.
33+
I setup this Grunt file so when `grunt prod` is run an unminified version of the file will be created, and another minified verison of the file will be made. This way I can keep track of both version as I needed. The grunt task will first run the JS concatenator so that all the javascript files are turned into `dist/js/all-js.js`. Next the LESS files will be compiled into `dist/css/common.css` much like Example2. However, the next step takes the finished JS file, minifies it, and then saves a copy off with thte word "min" in it. So `all-js.js` becomes `all-js.min.js`.
3434

3535

3636
I think if you go with a two file setup (one minified, one not) that its important to create 2 different Grunt tasks. One with the minification and one without it that way if you need an unminified version of the file(s) you don't have to monkey with your primary grunt task.
@@ -43,4 +43,7 @@ I think if you go with a two file setup (one minified, one not) that its importa
4343

4444

4545
#Additional Notes
46-
For more information on the [.]()
46+
For more information visit the following links:
47+
48+
* [grunt-contrib-concat](https://github.com/gruntjs/grunt-contrib-concat)
49+
* [grunt-contrib-uglify](https://github.com/gruntjs/grunt-contrib-uglify)

Example4/README.md

+27-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
#Example4 Goals
2-
A you ready to "watch" something cool happen!? So you've got all of these awesome Grunt tasks, but who wants to type `grunt dev` each time they're working on something? Not me, so more than likely not you. This example will show you how to make it so Grunt tracks your file changes and runs any task(s) you want automatically.
2+
A you ready to "watch" something cool happen!? So you've got all of these awesome Grunt tasks, but who wants to type `grunt dev` (or whatever) each time they're working on something? Not me, so more than likely not you. This example will show you how to make it so Grunt tracks your file changes and runs any task(s) you want automatically.
33

44
#Example4 Explained
5-
Before I get into the Watch command I want to try and clarify something up front. The files that Grunt Watches do not have to be the same files that are associated with that task you want run (most of the time they will be, but its not required). For example you could have Grunt compile Less files on any change done to an HTML file. It might seem wasteful, but there is probably a perfect case for it. Again, commonly when you configure the Watch you will probably have it the same files that the actual task is associated with. It'll look redudant, but I'll do my best to explain it clearly below.
5+
Before I get into the Watch command I want to try and clarify something up front. The files that Grunt "watches" do not have to be the same files that are associated with that task you want run (most of the time they will be, but its not required). For example you could have Grunt compile Less files on any change done to an HTML file. It might seem wasteful, but there is probably a perfect case for it. Again, commonly when you configure the Watch you will probably have it the same files that the actual task is associated with. It'll look redudant, but I'll do my best to explain it clearly below.
66

7+
In each Watch configuration you need to pick what files the task needs to watch and what tasks to run.
8+
9+
onlyhtml: {
10+
files: ["src/test.html"],
11+
tasks: ["concat", "less"]
12+
},
13+
14+
Above is the confugation for `onlyhtml`. The Grunt Watch feature will only trigger when you save the `src/test.html` file. When you save the the test.html file it will run the `concat` and `less` task. Do an `npm install`, and then type `grunt watch:onlyhtml`. when you do this you'll see a message like `Waiting...`. This is Grunt Watch's way of telling you that its waiting for you to save a file. When save that file it'll run those tasks, and upon completion go back into the `Waiting...` state.
15+
16+
The Watch task has a `dev` and `prod` Watch configuration. The names of these configurations do not have to match the names used in the `grunt.registerTask("...")`.
17+
18+
#To run this Example
19+
20+
`grunt dev` will generate an unminified set of aggregated CSS and JS assets
21+
22+
`grunt prod` will generate an unminifed and minified set of aggregated CSS and JS assets
23+
24+
`grunt watch` will run the last configuration in the `watch` task. (In this case it would be `watch:prod`)
25+
26+
`grunt watch:dev` will be the same as `grunt dev`, but using the Watch feature.
27+
28+
`grunt watch:prod` will be the same as `grunt prod`, but using the Watch feature.
729

830

931
#Additional Notes
10-
For more information on the [.]()
32+
For more information visit the following links:
33+
34+
* [grunt-contrib-watch](https://github.com/gruntjs/grunt-contrib-watch)

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ Once you've done that all you need to do is open a command prompt to where you'v
1313
* Example1: A simple copy/paste of source files.
1414
* Example2: Compiling Less files
1515
* Example3: Minifying/Aggregating CSS and JS using multple tasks.
16-
* Example4: Grunt Watch - bringing it all together!
16+
* Example4: Grunt Watch - bringing it all together!
17+
* StopDoingThingsManually - my "admin" project of sort for managing all the examples.

0 commit comments

Comments
 (0)