Skip to content

Commit

Permalink
docs(comments): comment config blocks in gruntfile
Browse files Browse the repository at this point in the history
Help let newer people know what each config section is for
  • Loading branch information
eddiemonge committed Nov 15, 2013
1 parent b39a31d commit 3eac6c6
Showing 1 changed file with 105 additions and 63 deletions.
168 changes: 105 additions & 63 deletions templates/common/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,24 @@
// 'test/spec/**/*.js'

module.exports = function (grunt) {

// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);

// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);

// Define the configuration for all the tasks
grunt.initConfig({

// Project settings
yeoman: {
// configurable paths
app: require('./bower.json').appPath || 'app',
dist: 'dist'
},

// Watches files for changes and runs tasks based on the changed files
watch: {
coffee: {
files: ['<%%= yeoman.app %>/scripts/{,*/}*.coffee'],
Expand Down Expand Up @@ -49,17 +58,8 @@ module.exports = function (grunt) {
]
}
},
autoprefixer: {
options: ['last 1 version'],
dist: {
files: [{
expand: true,
cwd: '.tmp/styles/',
src: '{,*/}*.css',
dest: '.tmp/styles/'
}]
}
},

// The actual grunt server settings
connect: {
options: {
port: 9000,
Expand Down Expand Up @@ -92,6 +92,20 @@ module.exports = function (grunt) {
}
}
},

// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'Gruntfile.js',
'<%%= yeoman.app %>/scripts/{,*/}*.js'
]
},

// Empties folders to start fresh
clean: {
dist: {
files: [{
Expand All @@ -105,16 +119,21 @@ module.exports = function (grunt) {
},
server: '.tmp'
},
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'Gruntfile.js',
'<%%= yeoman.app %>/scripts/{,*/}*.js'
]

// Add vendor prefixed styles
autoprefixer: {
options: ['last 1 version'],
dist: {
files: [{
expand: true,
cwd: '.tmp/styles/',
src: '{,*/}*.css',
dest: '.tmp/styles/'
}]
}
},

// Compiles CoffeeScript to JavaScript
coffee: {
options: {
sourceMap: true,
Expand All @@ -139,6 +158,8 @@ module.exports = function (grunt) {
}]
}
},<% if (compassBootstrap) { %>

// Compiles Sass to CSS and generates necessary files if requested
compass: {
options: {
sassDir: '<%%= yeoman.app %>/styles',
Expand All @@ -160,11 +181,8 @@ module.exports = function (grunt) {
}
}
},<% } %>
// not used since Uglify task does concat,
// but still available if needed
// concat: {
// dist: {}
// },

// Renames files for browser caching purposes
rev: {
dist: {
files: {
Expand All @@ -177,19 +195,27 @@ module.exports = function (grunt) {
}
}
},

// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
html: '<%%= yeoman.app %>/index.html',
options: {
dest: '<%%= yeoman.dist %>'
}
},

// Performs rewrites based on rev and the useminPrepage configuration
usemin: {
html: ['<%%= yeoman.dist %>/{,*/}*.html'],
css: ['<%%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
assetsDirs: ['<%%= yeoman.dist %>']
}
},

// The following *-min tasks produce minified files in the dist folder
imagemin: {
dist: {
files: [{
Expand All @@ -210,31 +236,10 @@ module.exports = function (grunt) {
}]
}
},
// By default, your `index.html` <!-- Usemin Block --> will take care of
// minification. This option is pre-configured if you do not wish to use
// Usemin blocks.
// cssmin: {
// dist: {
// files: {
// '<%%= yeoman.dist %>/styles/main.css': [
// '.tmp/styles/{,*/}*.css',
// '<%%= yeoman.app %>/styles/{,*/}*.css'
// ]
// }
// }
// },
// uglify: {
// dist: {
// files: {
// '<%%= yeoman.dist %>/scripts/scripts.js': [
// '<%%= yeoman.dist %>/scripts/scripts.js'
// ]
// }
// }
// },
htmlmin: {
dist: {
options: {
// Optional configurations that you can uncomment to use
// removeCommentsFromCDATA: true,
// collapseBooleanAttributes: true,
// removeAttributeQuotes: true,
Expand All @@ -251,7 +256,28 @@ module.exports = function (grunt) {
}]
}
},
// Put files not handled in other tasks here

// Allow the use of non-minsafe AngularJS files. Automatically makes it
// minsafe compatible so Uglify does not destroy the ng references
ngmin: {
dist: {
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts'
}]
}
},

// Replace Google CDN references
cdnify: {
dist: {
html: ['<%%= yeoman.dist %>/*.html']
}
},

// Copies remaining files to places other tasks can use
copy: {
dist: {
files: [{
Expand Down Expand Up @@ -282,6 +308,8 @@ module.exports = function (grunt) {
src: '{,*/}*.css'
}
},

// Run some tasks in parallel to speed up the build process
concurrent: {
server: [
'coffee:dist',<% if (compassBootstrap) { %>
Expand All @@ -302,29 +330,43 @@ module.exports = function (grunt) {
'htmlmin'
]
},

// By default, your `index.html`'s <!-- Usemin block --> will take care of
// minification. These next options are pre-configured if you do not wish
// to use the Usemin blocks.
// cssmin: {
// dist: {
// files: {
// '<%%= yeoman.dist %>/styles/main.css': [
// '.tmp/styles/{,*/}*.css',
// '<%%= yeoman.app %>/styles/{,*/}*.css'
// ]
// }
// }
// },
// uglify: {
// dist: {
// files: {
// '<%%= yeoman.dist %>/scripts/scripts.js': [
// '<%%= yeoman.dist %>/scripts/scripts.js'
// ]
// }
// }
// },
// concat: {
// dist: {}
// },

// Test settings
karma: {
unit: {
configFile: 'karma.conf.js',
singleRun: true
}
},
cdnify: {
dist: {
html: ['<%%= yeoman.dist %>/*.html']
}
},
ngmin: {
dist: {
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts'
}]
}
}
});


grunt.registerTask('serve', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
Expand Down

0 comments on commit 3eac6c6

Please sign in to comment.