Gruntfile.js
// Generated on 2013-07-31 using generator-angular 0.3.1
'use strict';
var path = require('path');
module.exports = function (grunt) {
var matchdep = require('matchdep');
// load all grunt tasks
matchdep.filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var yeomanConfig = {
app: 'app',
dist: 'dist'
};
try {
yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app;
} catch (e) {
}
grunt.initConfig({
yeoman: yeomanConfig,
env: {
dev: {
NODE_ENV: 'development',
DEST: 'app'
},
dist: {
NODE_ENV: 'production',
DEST: 'dist'
}
},
bower: {
install: {
options: {
targetDir: '<%= yeoman.app %>/bower_components',
install: true,
verbose: true,
cleanTargetDir: true
}
}
},
watch: {
coffee: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
tasks: ['coffee:dist']
},
coffeeTest: {
files: ['test/spec/{,*/}*.coffee'],
tasks: ['coffee:test']
}
},
express: {
options: {
port: 3000,
hostname: 'localhost'
},
livereload: {
options: {
server: path.resolve('./app.js'),
livereload: true,
serverreload: false,
bases: [path.resolve('./.tmp'), path.resolve(__dirname, yeomanConfig.app)]
}
},
test: {
options: {
port: 9001,
server: path.resolve('./app.js'),
bases: [path.resolve('./.tmp'), path.resolve(__dirname, 'test')]
}
},
dist: {
options: {
server: path.resolve('./app.js'),
bases: path.resolve(__dirname, yeomanConfig.dist)
}
}
},
open: {
server: {
url: 'http://localhost:<%= express.options.port %>'
}
},
clean: {
dist: {
files: [
{
dot: true,
src: [
'.tmp',
'<%= yeoman.dist %>/*',
'!<%= yeoman.dist %>/.git*'
]
}
]
},
server: {
files: [
{
src: [
'.tmp',
'coverage'
]
}
]
}
},
jshint: {
options: {
jshintrc: '.jshintrc',
ignores: [
'<%= yeoman.app %>/scripts/libs/{,*/}*.js',
'test/libs/{,*/}*.js'
]
},
all: [
'Gruntfile.js',
'<%= yeoman.app %>/scripts/{,*/}*.js',
'test/{,*/}*.js',
'app.js',
'backend/{,*/}*.js'
]
},
coffee: {
dist: {
files: [
{
expand: true,
cwd: '<%= yeoman.app %>/scripts',
src: '{,*/}*.coffee',
dest: '.tmp/scripts',
ext: '.js'
}
]
},
test: {
files: [
{
expand: true,
cwd: 'test/spec',
src: '{,*/}*.coffee',
dest: '.tmp/spec',
ext: '.js'
}
]
}
},
rev: {
dist: {
files: {
src: [
'<%= yeoman.dist %>/scripts/{,*/}*.js',
'<%= yeoman.dist %>/styles/{,*/}*.css',
//'<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'<%= yeoman.dist %>/styles/fonts/*'
]
}
}
},
useminPrepare: {
html: '<%= yeoman.app %>/views/index.html',
options: {
dest: '<%= yeoman.dist %>/views'
}
},
usemin: {
html: ['<%= yeoman.dist %>/views/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
basedir: '<%= yeoman.dist %>',
dirs: '<%= yeoman.dist %>'
}
},
imagemin: {
dist: {
files: [
{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg}',
dest: '<%= yeoman.dist %>/images'
}
]
}
},
svgmin: {
dist: {
files: [
{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.svg',
dest: '<%= yeoman.dist %>/images'
}
]
}
},
cssmin: {
// 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.
// dist: {
// files: {
// '<%= yeoman.dist %>/styles/main.css': [
// '.tmp/styles/{,*/}*.css',
// '<%= yeoman.app %>/styles/{,*/}*.css'
// ]
// }
// }
},
htmlmin: {
dist: {
options: {
//removeComments: true,
//collapseWhitespace: true
/*removeCommentsFromCDATA: true,
// https://github.com/yeoman/grunt-usemin/issues/44
//collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeOptionalTags: true*/
},
files: [
{
expand: true,
cwd: '<%= yeoman.app %>/views',
src: ['*.html', 'partials/{,*/}*.html'],
dest: '<%= yeoman.dist %>/views'
}
]
}
},
// Put files not handled in other tasks here
copy: {
dist: {
files: [
{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,png,txt}',
//'*.html', 'views/*.html',
'.htaccess',
'bower_components/**/*',
'images/{,*/}*.{gif,webp}',
'styles/fonts/*'
]
},
{
expand: true,
cwd: '.tmp/images',
dest: '<%= yeoman.dist %>/images',
src: [
'generated/*'
]
}
]
}
},
concurrent: {
server: [
'coffee:dist'
],
test: [
'coffee'
],
dist: [
'coffee',
'imagemin',
'svgmin'
]
},
karma: {
unit: {
configFile: 'karma.conf.js',
singleRun: true,
autoWatch: false
},
e2e: {
configFile: 'karma-e2e.conf.js',
singleRun: true
}
},
cdnify: {
dist: {
html: ['<%= yeoman.dist %>/{,*/}*.html']
}
},
ngmin: {
dist: {
files: [
{
expand: true,
cwd: '<%= yeoman.dist %>/scripts',
src: '*.js',
dest: '<%= yeoman.dist %>/scripts'
}
]
}
},
uglify: {
options: {
mangle: false
},
dist: {
files: {
'dist/scripts/scripts.js': [
'dist/scripts/scripts.js'
]
}
}
},
processhtml: {
options: {
},
dist: {
files: {
'dist/views/index.html': ['dist/views/index.html']
}
}
}
});
grunt.registerTask('server', function (target) {
if (target === 'dist') {
return grunt.task.run(['env:dist', 'build', 'express:dist', 'open', 'express-keepalive']);
}
grunt.task.run([
'env:dev',
'clean:server',
'bower',
'concurrent:server',
'express:livereload',
'open',
'watch'
]);
});
grunt.registerTask('test', function (target) {
if (target === 'dist') {
grunt.task.run(['env:dist']);
} else {
grunt.task.run(['env:dev', 'bower']);
}
grunt.task.run([
'clean:server',
'concurrent:test',
'express:test',
'karma'
]);
});
grunt.registerTask('build', [
'clean:dist',
'bower',
'useminPrepare',
'concurrent:dist',
'concat',
'copy',
'cdnify',
'ngmin',
'cssmin',
'htmlmin',
'uglify',
'rev',
'processhtml',
'usemin'
]);
grunt.registerTask('heroku:production',
'env:dist',
'build'
);
grunt.registerTask('default', [
'jshint',
'build',
'test:dist'
]);
};