Created
December 12, 2013 13:18
-
-
Save benjaminach/7927812 to your computer and use it in GitHub Desktop.
Gruntfile to complie bootstrap with numergy theme
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
| /* jshint node: true */ | |
| module.exports = function (grunt) { | |
| "use strict"; | |
| grunt.initConfig({ | |
| pkg: grunt.file.readJSON('package.json'), | |
| datetime: Date.now(), | |
| clean: { | |
| dist: ['dist'], | |
| tmp: ['dist/tmp'] | |
| }, | |
| concat: { | |
| 'bootstrap-js': { | |
| src: [ | |
| 'bower_components/bootstrap/js/transition.js', | |
| 'bower_components/bootstrap/js/alert.js', | |
| 'bower_components/bootstrap/js/button.js', | |
| 'bower_components/bootstrap/js/carousel.js', | |
| 'bower_components/bootstrap/js/collapse.js', | |
| 'bower_components/bootstrap/js/dropdown.js', | |
| 'bower_components/bootstrap/js/modal.js', | |
| 'bower_components/bootstrap/js/tooltip.js', | |
| 'bower_components/bootstrap/js/popover.js', | |
| 'bower_components/bootstrap/js/scrollspy.js', | |
| 'bower_components/bootstrap/js/tab.js', | |
| 'bower_components/bootstrap/js/affix.js' | |
| ], | |
| dest: 'dist/tmp/js/bootstrap.js' | |
| }, | |
| 'libs-js': { | |
| src: [ | |
| 'bower_components/respond/respond.src.js', | |
| 'bower_components/jquery/jquery.js', | |
| 'dist/tmp/js/modernizr-custom.js' | |
| ], | |
| dest: 'dist/tmp/js/libs.js' | |
| }, | |
| 'app-js': { | |
| src: [ | |
| 'dist/tmp/js/libs.js', | |
| 'dist/tmp/js/bootstrap.js' | |
| ], | |
| dest: 'dist/js/numergy.js' | |
| } | |
| }, | |
| uglify: { | |
| 'options': { | |
| report: 'min', | |
| mangle: { | |
| toplevel: true | |
| }, | |
| squeeze: { | |
| dead_code: false | |
| }, | |
| codegen: { | |
| quote_keys: true | |
| } | |
| }, | |
| 'app-js': { | |
| src: 'dist/js/numergy.js', | |
| dest: 'dist/js/numergy.min.js' | |
| } | |
| }, | |
| /* | |
| recess: { | |
| dist: { | |
| options: { | |
| compile: true, | |
| compress:true, | |
| }, | |
| files: { | |
| 'dist/css/numergy.css': ['less/custom-bootstrap.less'] | |
| } | |
| } | |
| } | |
| */ | |
| less: { | |
| development: { | |
| files: { | |
| "dist/css/numergy.css": "less/custom-bootstrap.less" | |
| } | |
| }, | |
| production: { | |
| options: { | |
| cleancss: true, | |
| compress: true, | |
| report: 'min' | |
| }, | |
| files: { | |
| "dist/css/numergy.min.css": "less/custom-bootstrap.less" | |
| } | |
| } | |
| }, | |
| copy: { | |
| fonts: { | |
| cwd: 'fonts/', | |
| src: ["**"], | |
| dest: 'dist/fonts', | |
| expand: true | |
| }, | |
| bootstrapfonts: { | |
| cwd: 'bower_components/bootstrap/fonts/', | |
| src: '**', | |
| dest: 'dist/fonts', | |
| expand: true | |
| }, | |
| styleguide: { | |
| src: 'style-guide/**', | |
| dest: 'dist/', | |
| expand: true | |
| }, | |
| styleguideassets: { | |
| cwd: 'dist/', | |
| src: ['fonts/**', 'css/**', 'images/**', 'js/**'], | |
| dest: 'dist/style-guide', | |
| expand: true | |
| }, | |
| bootstrapie7: { | |
| src: ["bower_components/bootstrap-ie7/css/bootstrap-ie7.css"], | |
| dest: 'dist/css/', | |
| flatten: true, | |
| expand: true | |
| }, | |
| boxsizingpolyfill: { | |
| src: ["bower_components/box-sizing-polyfill/boxsizing.htc"], | |
| dest: 'dist/js/', | |
| flatten: true, | |
| expand: true | |
| }, | |
| qunittests: { | |
| cwd: 'tests', | |
| src: '**', | |
| dest: 'dist/tmp/tests', | |
| expand: true | |
| }, | |
| qunitassets: { | |
| cwd: 'dist/', | |
| src: ['fonts/**', 'css/**', 'images/**', 'js/**'], | |
| dest: 'dist/tmp/tests', | |
| expand: true | |
| } | |
| }, | |
| modernizr: { | |
| "devFile": "bower_components/modernizr/modernizr.js", | |
| "outputFile": "dist/tmp/js/modernizr-custom.js", | |
| // Based on default settings on http://modernizr.com/download/ | |
| "extra": { | |
| "shiv": true, | |
| "printshiv": true, | |
| "load": false, | |
| "mq": false, | |
| "cssclasses": true | |
| }, | |
| // Based on default settings on http://modernizr.com/download/ | |
| "extensibility": { | |
| "addtest": false, | |
| "prefixed": false, | |
| "teststyles": false, | |
| "testprops": false, | |
| "testallprops": false, | |
| "hasevents": false, | |
| "prefixes": false, | |
| "domprefixes": false | |
| }, | |
| // By default, source is uglified before saving | |
| "uglify": false, | |
| "tests": [], | |
| "parseFiles": false, | |
| "matchCommunityTests": false, | |
| "customTests": [] | |
| }, | |
| validation: { | |
| options: { | |
| reset: true, | |
| path: 'dist/report/validation-status.json', | |
| reportpath: 'dist/report/validation-report.json', | |
| relaxerror: [ | |
| "Bad value X-UA-Compatible for attribute http-equiv on element meta.", | |
| "Element img is missing required attribute src." | |
| ] | |
| }, | |
| files: { | |
| src: ["dist/style-guide/index.html"] | |
| } | |
| }, | |
| csslint: { | |
| strict: { | |
| options: { | |
| csslintrc: 'less/.csslintrc', | |
| formatters: [{ | |
| id: 'csslint-xml', | |
| dest: 'dist/report/csslint.xml' | |
| }] | |
| }, | |
| src: ['dist/css/numergy.min.css'] | |
| } | |
| }, | |
| watch: { | |
| less: { | |
| files: 'less/*.less', | |
| tasks: ['less:development', 'less:production', 'copy:styleguideassets'] | |
| }, | |
| images: { | |
| files: ['images/*.png', 'images/*.jpg', 'images/*.gif'], | |
| tasks: ['imagemin', 'copy:styleguideassets'] | |
| } | |
| }, | |
| imagemin: { | |
| dynamic: { | |
| options: { | |
| pngquant: true | |
| }, | |
| files: [{ | |
| cwd: 'images/', | |
| src: ['**/*.{png,jpg,gif}'], | |
| dest: 'dist/images', | |
| expand: true | |
| }] | |
| } | |
| }, | |
| // Local server with live-reload | |
| connect: { | |
| iserver: { | |
| options: { | |
| port: 9001, | |
| base: 'dist/style-guide', | |
| keepalive: true | |
| } | |
| }, | |
| eserver: { | |
| options: { | |
| port: 9002, | |
| base: 'dist/style-guide', | |
| keepalive: true, | |
| hostname: '0.0.0.0' | |
| } | |
| }, | |
| testserver: { | |
| options: { | |
| port: 9003, | |
| base: 'dist/tmp/tests', | |
| keepalive: true | |
| } | |
| } | |
| }, | |
| compress: { | |
| main: { | |
| options: { | |
| archive: 'dist/numergy-bootstrap-theme.zip' | |
| }, | |
| files: [{ | |
| cwd: 'dist/css', | |
| src: ['**/*'], | |
| dest: 'css/', | |
| expand: true | |
| }, { | |
| cwd: 'dist/fonts', | |
| src: ['**/*'], | |
| dest: 'fonts/', | |
| expand: true | |
| }, { | |
| cwd: 'dist/images', | |
| src: ['**/*'], | |
| dest: 'images/', | |
| expand: true | |
| }, { | |
| cwd: 'dist/js', | |
| src: ['**/*'], | |
| dest: 'js/', | |
| expand: true | |
| }] | |
| } | |
| }, | |
| jshint: { | |
| options: { | |
| jshintrc: 'js/.jshintrc' | |
| }, | |
| gruntfile: { | |
| src: 'Gruntfile.js' | |
| }, | |
| src: { | |
| src: ['js/*.js'] | |
| } | |
| }, | |
| qunit: { | |
| options: { | |
| inject: 'dist/tmp/tests/bootstrap/unit/phantom.js' | |
| }, | |
| files: [ | |
| 'dist/tmp/tests/bootstrap/index.html' | |
| /*run, | |
| 'dist/tmp/tests/respond/index.html', | |
| 'dist/tmp/tests/modernizr/basic.html'*/ | |
| ] | |
| }, | |
| jsbeautifier: { | |
| modify: { | |
| src: ['Gruntfile.js'], | |
| options: { | |
| config: 'js/.jsbeautifyrc' | |
| } | |
| }, | |
| verify: { | |
| src: ['Gruntfile.js'], | |
| options: { | |
| mode: 'VERIFY_ONLY', | |
| config: 'js/.jsbeautifyrc' | |
| } | |
| } | |
| } | |
| //fin | |
| }); | |
| grunt.loadNpmTasks('grunt-contrib-concat'); | |
| grunt.loadNpmTasks('grunt-contrib-uglify'); | |
| //grunt.loadNpmTasks('grunt-recess'); | |
| grunt.loadNpmTasks('grunt-contrib-less'); | |
| grunt.loadNpmTasks('grunt-contrib-copy'); | |
| grunt.loadNpmTasks('grunt-contrib-clean'); | |
| grunt.loadNpmTasks("grunt-modernizr"); | |
| grunt.loadNpmTasks('grunt-html-validation'); | |
| grunt.loadNpmTasks("grunt-contrib-csslint"); | |
| grunt.loadNpmTasks('grunt-contrib-watch'); | |
| grunt.loadNpmTasks('grunt-contrib-imagemin'); | |
| grunt.loadNpmTasks('grunt-contrib-connect'); | |
| grunt.loadNpmTasks('grunt-contrib-compress'); | |
| grunt.loadNpmTasks('grunt-contrib-jshint'); | |
| grunt.loadNpmTasks('grunt-contrib-qunit'); | |
| grunt.loadNpmTasks('grunt-jsbeautifier'); | |
| grunt.loadNpmTasks('grunt-newer'); | |
| grunt.registerTask('default', [ | |
| 'clean:dist', | |
| 'modernizr', | |
| //'jshint', | |
| 'concat:bootstrap-js', | |
| 'concat:libs-js', | |
| 'concat:app-js', | |
| 'uglify:app-js', | |
| //'recess:dist', | |
| 'less:development', | |
| 'less:production', | |
| 'copy:fonts', | |
| 'copy:bootstrapfonts', | |
| 'copy:styleguide', | |
| 'copy:bootstrapie7', | |
| 'copy:styleguideassets', | |
| //'copy:qunittests', | |
| //'copy:qunitassets', | |
| 'copy:boxsizingpolyfill', | |
| 'imagemin', | |
| //'qunit', | |
| //'validation', | |
| //'csslint', | |
| //'compress:main' | |
| 'clean:tmp' | |
| ]); | |
| grunt.registerTask('verify', ['jsbeautifier:verify', 'jshint']); | |
| grunt.registerTask('cleanjs', ['jsbeautifier:modify', 'jshint']); | |
| grunt.registerTask('bttest', ['copy:qunittests', 'copy:qunitassets', 'qunit', 'clean:tmp']); | |
| grunt.registerTask('makezip', ['compress:main']); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment