88// 'test/spec/**/*.js'
99
1010module . exports = function ( grunt ) {
11+
12+ // Load grunt tasks automatically
1113 require ( 'load-grunt-tasks' ) ( grunt ) ;
14+
15+ // Time how long tasks take. Can help when optimizing build times
1216 require ( 'time-grunt' ) ( grunt ) ;
1317
18+ // Define the configuration for all the tasks
1419 grunt . initConfig ( {
20+
21+ // Project settings
1522 yeoman : {
1623 // configurable paths
1724 app : require ( './bower.json' ) . appPath || 'app' ,
1825 dist : 'dist'
1926 } ,
27+
28+ // Watches files for changes and runs tasks based on the changed files
2029 watch : {
2130 coffee : {
2231 files : [ '<%%= yeoman.app %>/scripts/{,*/}*.coffee' ] ,
@@ -49,17 +58,8 @@ module.exports = function (grunt) {
4958 ]
5059 }
5160 } ,
52- autoprefixer : {
53- options : [ 'last 1 version' ] ,
54- dist : {
55- files : [ {
56- expand : true ,
57- cwd : '.tmp/styles/' ,
58- src : '{,*/}*.css' ,
59- dest : '.tmp/styles/'
60- } ]
61- }
62- } ,
61+
62+ // The actual grunt server settings
6363 connect : {
6464 options : {
6565 port : 9000 ,
@@ -92,6 +92,20 @@ module.exports = function (grunt) {
9292 }
9393 }
9494 } ,
95+
96+ // Make sure code styles are up to par and there are no obvious mistakes
97+ jshint : {
98+ options : {
99+ jshintrc : '.jshintrc' ,
100+ reporter : require ( 'jshint-stylish' )
101+ } ,
102+ all : [
103+ 'Gruntfile.js' ,
104+ '<%%= yeoman.app %>/scripts/{,*/}*.js'
105+ ]
106+ } ,
107+
108+ // Empties folders to start fresh
95109 clean : {
96110 dist : {
97111 files : [ {
@@ -105,16 +119,21 @@ module.exports = function (grunt) {
105119 } ,
106120 server : '.tmp'
107121 } ,
108- jshint : {
109- options : {
110- jshintrc : '.jshintrc' ,
111- reporter : require ( 'jshint-stylish' )
112- } ,
113- all : [
114- 'Gruntfile.js' ,
115- '<%%= yeoman.app %>/scripts/{,*/}*.js'
116- ]
122+
123+ // Add vendor prefixed styles
124+ autoprefixer : {
125+ options : [ 'last 1 version' ] ,
126+ dist : {
127+ files : [ {
128+ expand : true ,
129+ cwd : '.tmp/styles/' ,
130+ src : '{,*/}*.css' ,
131+ dest : '.tmp/styles/'
132+ } ]
133+ }
117134 } ,
135+
136+ // Compiles CoffeeScript to JavaScript
118137 coffee : {
119138 options : {
120139 sourceMap : true ,
@@ -139,6 +158,8 @@ module.exports = function (grunt) {
139158 } ]
140159 }
141160 } , < % if ( compassBootstrap ) { % >
161+
162+ // Compiles Sass to CSS and generates necessary files if requested
142163 compass : {
143164 options : {
144165 sassDir : '<%%= yeoman.app %>/styles' ,
@@ -160,11 +181,8 @@ module.exports = function (grunt) {
160181 }
161182 }
162183 } , < % } % >
163- // not used since Uglify task does concat,
164- // but still available if needed
165- // concat: {
166- // dist: {}
167- // },
184+
185+ // Renames files for browser caching purposes
168186 rev: {
169187 dist : {
170188 files : {
@@ -177,19 +195,27 @@ module.exports = function (grunt) {
177195 }
178196 }
179197 } ,
198+
199+ // Reads HTML for usemin blocks to enable smart builds that automatically
200+ // concat, minify and revision files. Creates configurations in memory so
201+ // additional tasks can operate on them
180202 useminPrepare: {
181203 html : '<%%= yeoman.app %>/index.html' ,
182204 options : {
183205 dest : '<%%= yeoman.dist %>'
184206 }
185207 } ,
208+
209+ // Performs rewrites based on rev and the useminPrepage configuration
186210 usemin: {
187211 html : [ '<%%= yeoman.dist %>/{,*/}*.html' ] ,
188212 css : [ '<%%= yeoman.dist %>/styles/{,*/}*.css' ] ,
189213 options : {
190214 assetsDirs : [ '<%%= yeoman.dist %>' ]
191215 }
192216 } ,
217+
218+ // The following *-min tasks produce minified files in the dist folder
193219 imagemin: {
194220 dist : {
195221 files : [ {
@@ -210,31 +236,10 @@ module.exports = function (grunt) {
210236 } ]
211237 }
212238 } ,
213- // By default, your `index.html` <!-- Usemin Block --> will take care of
214- // minification. This option is pre-configured if you do not wish to use
215- // Usemin blocks.
216- // cssmin: {
217- // dist: {
218- // files: {
219- // '<%%= yeoman.dist %>/styles/main.css': [
220- // '.tmp/styles/{,*/}*.css',
221- // '<%%= yeoman.app %>/styles/{,*/}*.css'
222- // ]
223- // }
224- // }
225- // },
226- // uglify: {
227- // dist: {
228- // files: {
229- // '<%%= yeoman.dist %>/scripts/scripts.js': [
230- // '<%%= yeoman.dist %>/scripts/scripts.js'
231- // ]
232- // }
233- // }
234- // },
235239 htmlmin: {
236240 dist : {
237241 options : {
242+ // Optional configurations that you can uncomment to use
238243 // removeCommentsFromCDATA: true,
239244 // collapseBooleanAttributes: true,
240245 // removeAttributeQuotes: true,
@@ -251,7 +256,28 @@ module.exports = function (grunt) {
251256 } ]
252257 }
253258 } ,
254- // Put files not handled in other tasks here
259+
260+ // Allow the use of non-minsafe AngularJS files. Automatically makes it
261+ // minsafe compatible so Uglify does not destroy the ng references
262+ ngmin: {
263+ dist : {
264+ files : [ {
265+ expand : true ,
266+ cwd : '.tmp/concat/scripts' ,
267+ src : '*.js' ,
268+ dest : '.tmp/concat/scripts'
269+ } ]
270+ }
271+ } ,
272+
273+ // Replace Google CDN references
274+ cdnify: {
275+ dist : {
276+ html : [ '<%%= yeoman.dist %>/*.html' ]
277+ }
278+ } ,
279+
280+ // Copies remaining files to places other tasks can use
255281 copy: {
256282 dist : {
257283 files : [ {
@@ -282,6 +308,8 @@ module.exports = function (grunt) {
282308 src : '{,*/}*.css'
283309 }
284310 } ,
311+
312+ // Run some tasks in parallel to speed up the build process
285313 concurrent: {
286314 server : [
287315 'coffee:dist' , < % if ( compassBootstrap ) { % >
@@ -302,29 +330,43 @@ module.exports = function (grunt) {
302330 'htmlmin'
303331 ]
304332 } ,
333+
334+ // By default, your `index.html`'s <!-- Usemin block --> will take care of
335+ // minification. These next options are pre-configured if you do not wish
336+ // to use the Usemin blocks.
337+ // cssmin: {
338+ // dist: {
339+ // files: {
340+ // '<%%= yeoman.dist %>/styles/main.css': [
341+ // '.tmp/styles/{,*/}*.css',
342+ // '<%%= yeoman.app %>/styles/{,*/}*.css'
343+ // ]
344+ // }
345+ // }
346+ // },
347+ // uglify: {
348+ // dist: {
349+ // files: {
350+ // '<%%= yeoman.dist %>/scripts/scripts.js': [
351+ // '<%%= yeoman.dist %>/scripts/scripts.js'
352+ // ]
353+ // }
354+ // }
355+ // },
356+ // concat: {
357+ // dist: {}
358+ // },
359+
360+ // Test settings
305361 karma : {
306362 unit : {
307363 configFile : 'karma.conf.js' ,
308364 singleRun : true
309365 }
310- } ,
311- cdnify: {
312- dist : {
313- html : [ '<%%= yeoman.dist %>/*.html' ]
314- }
315- } ,
316- ngmin: {
317- dist : {
318- files : [ {
319- expand : true ,
320- cwd : '.tmp/concat/scripts' ,
321- src : '*.js' ,
322- dest : '.tmp/concat/scripts'
323- } ]
324- }
325366 }
326367 } ) ;
327368
369+
328370 grunt . registerTask ( 'serve ', function ( target ) {
329371 if ( target === 'dist' ) {
330372 return grunt . task . run ( [ 'build' , 'connect:dist:keepalive' ] ) ;
0 commit comments