|
| 1 | +/*global module:false*/ |
| 2 | +module.exports = function(grunt) { |
| 3 | + |
| 4 | + // Project configuration. |
| 5 | + grunt.initConfig({ |
| 6 | + // Metadata. |
| 7 | + pkg: grunt.file.readJSON('package.json'), |
| 8 | + |
| 9 | + banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + |
| 10 | + '<%= grunt.template.today("yyyy-mm-dd") %>\n' + |
| 11 | + '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + |
| 12 | + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>; */\n', |
| 13 | + |
| 14 | + // Task configuration. |
| 15 | + watch: { |
| 16 | + gurntfile: { |
| 17 | + files: 'Gruntfile.js', |
| 18 | + tasks: ['jshint:gruntfile'], |
| 19 | + }, |
| 20 | + less: { |
| 21 | + files: ['src/css/*.less'], |
| 22 | + tasks: ['recess'] |
| 23 | + }, |
| 24 | + javascript: { |
| 25 | + files: ['src/js/*.js'], |
| 26 | + tasks: ['concat'] |
| 27 | + } |
| 28 | + }, |
| 29 | + |
| 30 | + clean: ['dist'], |
| 31 | + |
| 32 | + copy: { |
| 33 | + dev: { |
| 34 | + files: [ |
| 35 | + { expand: true, cwd: 'src/', src: '*.{ico,txt}', dest: 'dist/' }, |
| 36 | + { src: 'src/lib/modernizr/modernizr-2.6.2.js', dest: 'dist/js/modernizr.js' }, |
| 37 | + { src: 'src/lib/jquery/jquery-2.0.3.js', dest: 'dist/js/jquery.js' }, |
| 38 | + { expand: true, cwd: 'src/lib/bootstrap/', src: ['fonts/**'], dest: 'dist/' } |
| 39 | + ] |
| 40 | + }, |
| 41 | + release: { |
| 42 | + files: [ |
| 43 | + { expand: true, cwd: 'src/', src: '*.{ico,txt}', dest: 'dist/' }, |
| 44 | + { src: 'src/lib/modernizr/modernizr-2.6.2.min.js', dest: 'dist/js/modernizr.js' }, |
| 45 | + { src: 'src/lib/jquery/jquery-2.0.3.min.js', dest: 'dist/js/jquery.js' }, |
| 46 | + { src: 'src/lib/jquery/jquery-2.0.3.min.map', dest: 'dist/js/jquery.min.map' }, |
| 47 | + { expand: true, cwd: 'src/lib/bootstrap/', src: ['fonts/**'], dest: 'dist/' } |
| 48 | + ] |
| 49 | + } |
| 50 | + }, |
| 51 | + |
| 52 | + recess: { |
| 53 | + options: { |
| 54 | + compile: true, |
| 55 | + compress: false |
| 56 | + }, |
| 57 | + bootstrap: { |
| 58 | + src: ['src/lib/bootstrap/less/bootstrap.less'], |
| 59 | + dest: 'dist/css/bootstrap.css' |
| 60 | + }, |
| 61 | + app: { |
| 62 | + src: ['src/css/app.less'], |
| 63 | + dest: 'dist/css/app.css' |
| 64 | + } |
| 65 | + }, |
| 66 | + |
| 67 | + concat: { |
| 68 | + options: { |
| 69 | + banner: '<%= banner %>', |
| 70 | + stripBanners: true |
| 71 | + }, |
| 72 | + bootstrap: { |
| 73 | + src: [ |
| 74 | + 'src/lib/bootstrap/js/transition.js', |
| 75 | + 'src/lib/bootstrap/js/button.js', |
| 76 | + 'src/lib/bootstrap/js/dropdown.js', |
| 77 | + 'src/lib/bootstrap/js/modal.js' |
| 78 | + ], |
| 79 | + dest: 'dist/js/bootstrap.js' |
| 80 | + }, |
| 81 | + app: { |
| 82 | + src: ['src/js/app.js'], |
| 83 | + dest: 'dist/js/app.js' |
| 84 | + } |
| 85 | + }, |
| 86 | + |
| 87 | + uglify: { |
| 88 | + options: { |
| 89 | + banner: '<%= banner %>', |
| 90 | + mangle: { |
| 91 | + except: [] |
| 92 | + }, |
| 93 | + preserveComments: false |
| 94 | + }, |
| 95 | + bootstrap: { |
| 96 | + src: '<%= concat.bootstrap.dest %>', |
| 97 | + dest: '<%= concat.bootstrap.dest %>', |
| 98 | + }, |
| 99 | + app: { |
| 100 | + src: '<%= concat.app.dest %>', |
| 101 | + dest: '<%= concat.app.dest %>', |
| 102 | + } |
| 103 | + }, |
| 104 | + |
| 105 | + jshint: { |
| 106 | + options: { |
| 107 | + curly: true, |
| 108 | + eqeqeq: true, |
| 109 | + immed: true, |
| 110 | + latedef: true, |
| 111 | + newcap: true, |
| 112 | + noarg: true, |
| 113 | + sub: true, |
| 114 | + undef: true, |
| 115 | + unused: true, |
| 116 | + boss: true, |
| 117 | + eqnull: true, |
| 118 | + browser: true, |
| 119 | + globals: {} |
| 120 | + }, |
| 121 | + gruntfile: { |
| 122 | + src: 'Gruntfile.js' |
| 123 | + } |
| 124 | + }, |
| 125 | + |
| 126 | + connect: { |
| 127 | + server: { |
| 128 | + options: { |
| 129 | + keepalive: true, |
| 130 | + port: 5001, |
| 131 | + base: 'dist' |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + }); |
| 136 | + |
| 137 | + // These plugins provide necessary tasks. |
| 138 | + grunt.loadNpmTasks('grunt-contrib-clean'); |
| 139 | + grunt.loadNpmTasks('grunt-contrib-copy'); |
| 140 | + grunt.loadNpmTasks('grunt-contrib-concat'); |
| 141 | + grunt.loadNpmTasks('grunt-contrib-uglify'); |
| 142 | + grunt.loadNpmTasks('grunt-contrib-jshint'); |
| 143 | + grunt.loadNpmTasks('grunt-contrib-watch'); |
| 144 | + grunt.loadNpmTasks('grunt-contrib-connect'); |
| 145 | + grunt.loadNpmTasks('grunt-recess'); |
| 146 | + |
| 147 | + // Default task. |
| 148 | + grunt.registerTask('default', ['jshint', 'clean', 'copy:dev', 'recess', 'concat']); |
| 149 | + grunt.registerTask('release', ['jshint', 'clean', 'copy:release', 'recess', 'concat', 'uglify']); |
| 150 | + |
| 151 | +}; |
0 commit comments