Created
December 23, 2014 13:36
-
-
Save cyclopslabs/7ad48eaf2a96c13a1307 to your computer and use it in GitHub Desktop.
Complete Grunt File
This file contains 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) { | |
/* | |
* **************************** | |
* Tasks | |
* **************************** | |
*/ | |
/* | |
* Default - Distribution | |
* runs jsHint and karma unit tests | |
* builds docs | |
* concat, uglify, minifies | |
* create zip | |
* | |
* type: grunt | |
*/ | |
grunt.registerTask('default', [ | |
'hintAndTest', | |
'clean:build', | |
'docs', | |
'processhtml', | |
'htmlmin', | |
'ngtemplates', | |
'concat', 'uglify', | |
'cssmin', 'copy', | |
'compress' | |
]); | |
/* | |
* Build Fast (just in case) - Distribution | |
* Same as default, but doesn't lint, doesn't run unit tests | |
* doesn't generate docs | |
* | |
* type: grunt buildfast | |
*/ | |
grunt.registerTask('buildfast', [ | |
'clean:build', | |
'processhtml', | |
'htmlmin', | |
'ngtemplates', | |
'concat', 'uglify', | |
'cssmin', 'copy' | |
]); | |
/* | |
* devjs - for development | |
* Just concats the js | |
* | |
* type: grunt devjs | |
*/ | |
grunt.registerTask('devjs', ['clean:dev', | |
'htmlmin','ngtemplates', 'concat']); | |
/* | |
* dev | |
* concats the js and css and moves them along with images | |
* | |
* Type: grunt dev | |
*/ | |
grunt.registerTask('dev', ['clean:dev', | |
'htmlmin', 'ngtemplates', 'concat', 'cssmin', 'copy']); | |
/* | |
* *********************** | |
* Sub tasks - you can call these on their own, but they are mainly for | |
* the main tasks to use. | |
* *********************** | |
*/ | |
/* | |
* docs | |
* generates documentation | |
*/ | |
grunt.registerTask('docs', ['clean:docs', 'ngdocs'] ); | |
/* | |
* hint | |
* runs jshint and starts a watcher | |
*/ | |
grunt.registerTask('hint', ['jshint', 'watch']); | |
/* | |
* test | |
* runs the unit tests | |
* running karma in this way starts it's own watcher | |
*/ | |
grunt.registerTask('test', ['karma']); | |
/* | |
* Hint and test (no watchers) | |
*/ | |
grunt.registerTask('hintAndTest', ['jshint','karma:build',]); | |
// configuration: | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
clean: { | |
build: ['distribution', 'build', 'dist', 'dccs', 'coverage', '*.zip'], | |
dev : ['build'], | |
docs: ['docs'] | |
}, | |
concat: { | |
options: { | |
separator: ';' | |
}, | |
dist: { | |
src: [ | |
'vendor/angular.js', | |
'vendor/angular-route.js', | |
'vendor/angular-ui-router.js', | |
'vendor/angular-animate.js', | |
'vendor/angular-loading-bar.js', | |
'vendor/angular-toaster.js', | |
'vendor/modal/transition.js', | |
'vendor/modal/modal.js', | |
'app/app.js', | |
'app/config/*.js', | |
'app/components/*.js', | |
'app/components/**/*.*.js', | |
'app/components/**/*.js', | |
'app/components/**/**/*.*.js', | |
'app/components/**/**/*.js', | |
'app/components/**/**/**/*.*.js', | |
'app/components/**/**/**/*.js', | |
'<%= ngtemplates.app.dest %>', | |
'!app/app.spec.js,', | |
'!app/**/*.*.spec.js,', | |
'!app/**/**/*.spec.js', | |
'!app/**/**/*.*.spec.js' | |
], | |
dest: 'build/<%= pkg.name %>.js' | |
} | |
}, | |
uglify: { | |
options : { | |
banner: '/*! \n' + | |
'<%= pkg.description %> \n' + | |
'Compiled on: <%- grunt.template.today() %> \n \n' + | |
'\t\t--- PROPRIETARY NOTICE --- \n' + | |
'<%= pkg.copyrightMain %> \n \n' + | |
'Copyright <%- grunt.template.today("yyyy") %>, *************** LLC. \n' + | |
'\n \n ' + | |
'\t\t--- 3RD PARTY / OPEN SOURCE SOFTWARE --- \n' + | |
'The open source software listed below is the property of the individuals and organizations listed:\n' + | |
'AngularJs \t\t https://github.com/angular/angular.js/blob/master/LICENSE \n' + | |
'*/ \n' | |
}, | |
build : { | |
src: 'build/<%= pkg.name %>.js', | |
dest: 'distribution/js/<%= pkg.name %>.min.js' | |
} | |
}, | |
cssmin: { | |
compress: { | |
files: { | |
'distribution/css/<%= pkg.name %>.min.css': | |
[ | |
'assets/css/reset.css', | |
'assets/css/angular-loading-bar.css', | |
'assets/css/angular-toaster.css', | |
'assets/css/app.css'] | |
} | |
} | |
}, | |
copy: { | |
fonts: { | |
expand: true, | |
cwd: 'assets/css/font/', | |
src: '**', | |
dest: 'distribution/css/font/', | |
flatten: true, | |
filter: 'isFile' | |
}, | |
images: { | |
expand: true, | |
cwd: 'assets/images', | |
src: '**', | |
dest: 'distribution/images', | |
flatten: false, | |
filter: 'isFile' | |
} | |
}, | |
ngtemplates: { | |
app: { | |
src: ['app/**/*.tpl.html', 'app/**/*.html'], | |
dest: 'build/templates.js', | |
options:{ | |
module: 'app', | |
htmlmin: { | |
collapseWhitespace: true, | |
removeComments: true | |
} | |
} | |
} | |
}, | |
htmlmin: { | |
dist: { | |
options: { | |
removeComments: true, | |
collapseWhitespace : true, | |
}, | |
files: { | |
'distribution/index.html': 'build/index.html' | |
} | |
} | |
}, | |
processhtml : { | |
dist: { | |
files: { | |
'build/index.html': ['index.html'] | |
} | |
} | |
}, | |
ngdocs: { | |
options: { | |
dest: 'docs', | |
startPage : '/api/fe-app', | |
title: 'Front End API Documentation', | |
html5mode: false | |
}, | |
all: [ | |
'app/**/*.js' | |
] | |
}, | |
jshint:{ | |
options: { | |
jshintrc: true | |
}, | |
app: { | |
files : { | |
src : [ | |
'app/*.js', | |
'app/config/**/*.js', | |
'app/fakeBackend/**/*.js' | |
] | |
}, | |
}, | |
login: { | |
files: { | |
src: [ | |
'app/components/login/*.js' | |
] | |
} | |
}, | |
common: { | |
files: { | |
src: [ | |
'app/components/common/**/*.js' | |
] | |
} | |
}, | |
streamingData: { | |
files: { | |
src: [ | |
'app/components/streaming-data/**/*.js' | |
] | |
} | |
}, | |
reports: { | |
files: { | |
src: [ | |
'app/components/reports/**/*.js' | |
] | |
} | |
}, | |
dataload: { | |
files: { | |
src: [ | |
'app/components/dataload/**/*.js' | |
] | |
} | |
}, | |
hardwareTests: { | |
files: { | |
src: [ | |
'app/components/hardware-tests/**/*.js' | |
] | |
} | |
}, | |
externalMemoryManager: { | |
files: { | |
src: [ | |
'app/components/external-memory-manager/**/*.js' | |
] | |
} | |
} | |
}, | |
karma: { | |
unit: { | |
configFile: 'test/karma.conf.js' | |
}, | |
build: { | |
configFile: 'test/karma.conf.js', | |
singleRun: true | |
} | |
}, | |
watch: { | |
scripts: { | |
files: [ | |
'Gruntfile.js', | |
'app/app.js', | |
'app/config/*.js', | |
'app/**/*.js' | |
], | |
options: { spawn: false }, | |
tasks: ['jshint'] | |
} | |
}, | |
compress: { | |
main: { | |
options: { | |
archive: '<%= pkg.systemname %>.zip' | |
}, | |
expand: true, | |
cwd: 'distribution/', | |
src: '**/*' | |
} | |
}, | |
// This doesn't work without editing the docular package source code | |
// due to the proxy. | |
// Possible TODO. | |
// Docular generates nicer looking documentation, but my time might be | |
// better spent just editing CSS for ngdocs | |
docular: { | |
useHtml5Mode: false, | |
docular_webapp_target: '/docs', | |
showAngularDocs: false, //"1.2.24", | |
showDocularDocs: false //true | |
} | |
}); | |
/********* load task plugins *************/ | |
grunt.loadNpmTasks('grunt-contrib-clean'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-contrib-copy'); | |
grunt.loadNpmTasks('grunt-ngdocs'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-karma'); | |
grunt.loadNpmTasks('grunt-angular-templates'); | |
grunt.loadNpmTasks('grunt-contrib-htmlmin'); | |
grunt.loadNpmTasks('grunt-processhtml'); | |
grunt.loadNpmTasks('grunt-contrib-compress'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment