Skip to content

Instantly share code, notes, and snippets.

@punmechanic
Created September 20, 2014 15:30
Show Gist options
  • Save punmechanic/7f5282be7145b73ce3c7 to your computer and use it in GitHub Desktop.
Save punmechanic/7f5282be7145b73ce3c7 to your computer and use it in GitHub Desktop.
A template Gruntfile.js template for AngularJS projects
module.exports = function(grunt) {
grunt.initConfig({
revision: {
options: {
short: true,
ref: 'HEAD',
property: 'meta.revision'
}
},
karma: {
unit: {
configFile: 'karma.unit.conf.js'
}
},
protractor: {
e2e: {
configFile: 'protractor.e2e.conf.js'
}
},
uglify: {
package: {
files: {'dist/app-<%=meta.revision%>.min.js': 'dist/app-<%=meta.revision%>.js'},
options: { 'mangle': false }
}
},
jshint: {
all: ['Gruntfile.js', 'src/*.js', 'src/**/*.js']
},
concat: {
options: {
separator: ';'
},
package: {
src: [
'src/*.js',
'src/**/*.js',
'tmp/templates.js'
],
dest: 'dist/app-<%=meta.revision%>.js'
}
},
html2js: {
options: {
singleModule: true,
quoteChar: '\''
},
package: {
src: ['src/**/*.tpl.html'],
dest: 'tmp/templates.js',
prefix: 'src',
module: 'app.templates'
}
},
clean: {
'post-package': ['tmp/'],
'pre-package': ['dist/']
}
});
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-html2js');
grunt.loadNpmTasks('grunt-git-revision');
grunt.registerTask('default', ['test']);
grunt.registerTask('test', ['unit', 'e2e']);
grunt.registerTask('pre-package', ['revision', 'clean:pre-package']);
grunt.registerTask('package', [
'pre-package',
'jshint',
'html2js:package',
'concat:package',
'uglify:package',
'clean:post-package']);
grunt.registerTask('unit', ['karma:unit']);
grunt.registerTask('e2e', ['protractor:e2e']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment