UNPKG

chicago

Version:

A front-end JavaScript library for user-interface developers.

217 lines (199 loc) 4.34 kB
/*global module : false*/ module.exports = function(grunt) { // ======================================================================== // Grunt modules // ======================================================================== require('load-grunt-tasks')(grunt); // Project configuration. grunt.initConfig({ pkg : grunt.file.readJSON('package.json'), banner : '/*!\n' + ' * <%= pkg.title || pkg.name %> - <%= pkg.description %>\n' + ' * \n' + ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>\n' + ' * \n' + ' * Licensed under the MIT license:\n' + ' * http://www.opensource.org/licenses/mit-license.php\n' + ' * \n' + ' * Project home:\n' + ' * <%= pkg.homepage %>\n' + ' * \n' + ' * Version: <%= pkg.version %>\n' + ' * \n' + ' */\n\n', watch : { js : { files : [ 'src/**/*.js', 'Gruntfile.js' ], tasks : [ 'newer:uglify', 'build-js' ] }, }, concat : { options : { banner : '<%= banner %>', stripBanners : true }, core : { src : [ // Prototype extensions 'tmp/prototype/array.js', // Core files 'tmp/core/core.js', 'tmp/core/browser.js', // Events 'tmp/core/events.js', ], dest : 'dist/<%= pkg.name %>.js', }, }, uglify : { options : { // banner : '<%= banner %>', preserveComments : false, screwIE8 : true }, modules: { options: { preserveComments : 'some', mangle : false, compress : false, beautify : { beautify : true, bracketize : true }, }, files: [{ expand : true, cwd : 'src/modules', src : ['*.js'], dest : 'dist/modules', ext : '.js', extDot : 'last' }] }, min : { options : { banner : '<%= banner %>', mangle : {}, beautify : false, compress : { warnings : false }, beautify : false, expression : false, maxLineLen : 32000, ASCIIOnly : false }, files : [{ expand: true, cwd: 'dist', src: '**/*.js', dest: 'dist', ext : '.min.js', }] }, }, jsbeautifier : { options : { js : { indentChar: "\t", indentLevel : 0, indentSize: 1, indentWithTabs : true, maxPreserveNewlines : 2, spaceAfterAnonFunction : false, spaceBeforeConditional : false, } }, js : { src : ['dist/**/*.js'], filter : function(filepath) { return filepath.indexOf('.min') < 0 } }, }, clean : { tmp : [ 'tmp' ], dist : [ 'dist' ], test : [ 'test/results', 'test/lib' ] }, // style enforcement chicago : { core : { files : [{ expand : true, cwd : 'src', src : ['**/*.js'], dest : 'tmp', ext : '.js', extDot : 'last' }], } }, jscs : { src : ['dist/**/*.js', '!dist/**/*.min.js'], options: { config: '.jscsrc', force : true, reporter : require('jscs-html-reporter').path, reporterOutput : 'test/results/jscs/report.html', fix : true } }, // hinting/linting jshint : { options : { jshintrc : '.jshintrc', reporter : require('jshint-html-reporter'), reporterOutput : 'test/results/jshint/report.html', force : true }, all : ['dist/<%= pkg.name %>.js'] }, // tests mocha : { test : { src : ['test/mocha/*.html'], options : { run : true, mocha: { logErrors : false, ignoreLeaks : false, } } }, }, casperjs: { options : { async: { parallel: true } }, modal : { src: ['test/casper/modal.js'], } }, }); // Load Custom Tasks grunt.loadTasks('tasks'); grunt.registerTask( 'build-js', 'Builds, cleans, and optmiizes al .js', [ 'clean:tmp', 'clean:dist', 'chicago', 'concat', 'uglify:modules', 'jsbeautifier', 'clean:tmp' ] ); grunt.registerTask( 'build', 'Compiles and cleans all source files', [ 'build-js', 'chicago-style', 'jscs', 'uglify:min' ] ); grunt.registerTask( 'test', 'Runs all automated tests', [ 'build', 'clean:test', 'jshint', 'mocha', 'casperjs' ] ); grunt.registerTask( 'release', 'Runs all release tasks', [ 'build', 'update-version', 'npm-publish', 'bower-publish', 'changelog' ] ); grunt.registerTask( 'default', [ 'watch' ] ); };