Created
June 2, 2015 00:07
-
-
Save eugene-goldberg/c99d4d62fe3f96e73e65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
// Unified Watch Object | |
var watchFiles = { | |
serverViews: ['app/views/**/*.*'], | |
serverJS: ['gruntfile.js', 'server.js', 'config/**/*.js', 'app/**/*.js'], | |
clientViews: ['public/modules/**/views/**/*.html'], | |
clientJS: ['public/js/*.js', 'public/modules/**/*.js'], | |
clientCSS: ['public/modules/**/*.css'], | |
mochaTests: ['app/tests/**/*.js'] | |
}; | |
// Project Configuration | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
watch: { | |
serverViews: { | |
files: watchFiles.serverViews, | |
options: { | |
livereload: false | |
} | |
}, | |
serverJS: { | |
files: watchFiles.serverJS, | |
tasks: ['jshint'], | |
options: { | |
livereload: false | |
} | |
}, | |
clientViews: { | |
files: watchFiles.clientViews, | |
options: { | |
livereload: false | |
} | |
}, | |
clientJS: { | |
files: watchFiles.clientJS, | |
tasks: ['jshint'], | |
options: { | |
livereload: false | |
} | |
}, | |
clientCSS: { | |
files: watchFiles.clientCSS, | |
tasks: ['csslint'], | |
options: { | |
livereload: false | |
} | |
} | |
}, | |
jshint: { | |
all: { | |
src: watchFiles.clientJS.concat(watchFiles.serverJS), | |
options: { | |
jshintrc: true | |
} | |
} | |
}, | |
csslint: { | |
options: { | |
csslintrc: '.csslintrc', | |
}, | |
all: { | |
src: watchFiles.clientCSS | |
} | |
}, | |
uglify: { | |
production: { | |
options: { | |
mangle: false | |
}, | |
files: { | |
'public/dist/application.min.js': 'public/dist/application.js' | |
} | |
} | |
}, | |
cssmin: { | |
combine: { | |
files: { | |
'public/dist/application.min.css': '<%= applicationCSSFiles %>' | |
} | |
} | |
}, | |
nodemon: { | |
dev: { | |
script: 'server.js', | |
options: { | |
nodeArgs: ['--debug'], | |
ext: 'js,html', | |
watch: watchFiles.serverViews.concat(watchFiles.serverJS) | |
} | |
} | |
}, | |
'node-inspector': { | |
custom: { | |
options: { | |
'web-port': 1337, | |
'web-host': 'localhost', | |
'debug-port': 5858, | |
'save-live-edit': true, | |
'no-preload': true, | |
'stack-trace-limit': 50, | |
'hidden': [] | |
} | |
} | |
}, | |
ngAnnotate: { | |
production: { | |
files: { | |
'public/dist/application.js': '<%= applicationJavaScriptFiles %>' | |
} | |
} | |
}, | |
concurrent: { | |
default: ['nodemon', 'watch'], | |
debug: ['nodemon', 'watch', 'node-inspector'], | |
options: { | |
logConcurrentOutput: true, | |
limit: 10 | |
} | |
}, | |
env: { | |
test: { | |
NODE_ENV: 'test' | |
}, | |
secure: { | |
NODE_ENV: 'secure' | |
} | |
}, | |
mochaTest: { | |
src: watchFiles.mochaTests, | |
options: { | |
reporter: 'spec', | |
require: 'server.js' | |
} | |
}, | |
karma: { | |
unit: { | |
configFile: 'karma.conf.js' | |
} | |
} | |
}); | |
// Load NPM tasks | |
require('load-grunt-tasks')(grunt); | |
// Making grunt default to force in order not to break the project. | |
grunt.option('force', true); | |
// A Task for loading the configuration object | |
grunt.task.registerTask('loadConfig', 'Task that loads the config into a grunt option.', function() { | |
var init = require('./config/init')(); | |
var config = require('./config/config'); | |
grunt.config.set('applicationJavaScriptFiles', config.assets.js); | |
grunt.config.set('applicationCSSFiles', config.assets.css); | |
}); | |
// Default task(s). | |
grunt.registerTask('default', ['lint', 'concurrent:default']); | |
// Debug task. | |
grunt.registerTask('debug', ['lint', 'concurrent:debug']); | |
// Secure task(s). | |
grunt.registerTask('secure', ['env:secure', 'lint', 'concurrent:default']); | |
// Lint task(s). | |
grunt.registerTask('lint', ['jshint', 'csslint']); | |
// Build task(s). | |
grunt.registerTask('build', ['lint', 'loadConfig', 'ngAnnotate', 'uglify', 'cssmin']); | |
// Test task. | |
grunt.registerTask('test', ['env:test', 'mochaTest', 'karma:unit']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment