|
| 1 | +module.exports = function(grunt) { |
| 2 | + |
| 3 | + // Project configuration. |
| 4 | + grunt.initConfig({ |
| 5 | + // Metadata. |
| 6 | + pkg: grunt.file.readJSON('package.json'), |
| 7 | + banner: '/**\n' + |
| 8 | + '* <%= pkg.name %>.js v<%= pkg.version %> by @fat and @mdo\n' + |
| 9 | + '* Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' + |
| 10 | + '* <%= _.pluck(pkg.licenses, "url").join(", ") %>\n' + |
| 11 | + '*/\n', |
| 12 | + // Task configuration. |
| 13 | + clean: { |
| 14 | + dist: ['dist'] |
| 15 | + }, |
| 16 | + concat: { |
| 17 | + options: { |
| 18 | + banner: '<%= banner %>', |
| 19 | + stripBanners: false |
| 20 | + }, |
| 21 | + bootstrap: { |
| 22 | + src: ['js/*.js'], |
| 23 | + dest: 'dist/js/<%= pkg.name %>.js' |
| 24 | + } |
| 25 | + }, |
| 26 | + jshint: { |
| 27 | + options: { |
| 28 | + jshintrc: 'js/.jshintrc' |
| 29 | + }, |
| 30 | + gruntfile: { |
| 31 | + src: 'Gruntfile.js' |
| 32 | + }, |
| 33 | + src: { |
| 34 | + src: ['js/*.js'] |
| 35 | + }, |
| 36 | + test: { |
| 37 | + src: ['js/tests/unit/*.js'] |
| 38 | + } |
| 39 | + }, |
| 40 | + recess: { |
| 41 | + options: { |
| 42 | + compile: true |
| 43 | + }, |
| 44 | + bootstrap: { |
| 45 | + files: { |
| 46 | + 'dist/css/bootstrap.css': ['less/bootstrap.less'] |
| 47 | + } |
| 48 | + }, |
| 49 | + min: { |
| 50 | + options: { |
| 51 | + compress: true |
| 52 | + }, |
| 53 | + files: { |
| 54 | + 'dist/css/bootstrap.min.css': ['less/bootstrap.less'] |
| 55 | + } |
| 56 | + } |
| 57 | + }, |
| 58 | + uglify: { |
| 59 | + options: { |
| 60 | + banner: '<%= banner %>' |
| 61 | + }, |
| 62 | + bootstrap: { |
| 63 | + files: { |
| 64 | + 'dist/js/<%= pkg.name %>.min.js': ['<%= concat.bootstrap.dest %>'] |
| 65 | + } |
| 66 | + } |
| 67 | + }, |
| 68 | + qunit: { |
| 69 | + options: { |
| 70 | + inject: 'js/tests/unit/phantom.js' |
| 71 | + }, |
| 72 | + files: ['js/tests/*.html'] |
| 73 | + }, |
| 74 | + connect: { |
| 75 | + server: { |
| 76 | + options: { |
| 77 | + port: 3000, |
| 78 | + base: '.' |
| 79 | + } |
| 80 | + } |
| 81 | + }, |
| 82 | + watch: { |
| 83 | + src: { |
| 84 | + files: '<%= jshint.src.src %>', |
| 85 | + tasks: ['jshint:src', 'qunit'] |
| 86 | + }, |
| 87 | + test: { |
| 88 | + files: '<%= jshint.test.src %>', |
| 89 | + tasks: ['jshint:test', 'qunit'] |
| 90 | + }, |
| 91 | + recess: { |
| 92 | + files: 'less/*.less', |
| 93 | + tasks: ['recess'] |
| 94 | + } |
| 95 | + } |
| 96 | + }); |
| 97 | + |
| 98 | + |
| 99 | + // These plugins provide necessary tasks. |
| 100 | + grunt.loadNpmTasks('grunt-contrib-connect'); |
| 101 | + grunt.loadNpmTasks('grunt-contrib-clean'); |
| 102 | + grunt.loadNpmTasks('grunt-contrib-concat'); |
| 103 | + grunt.loadNpmTasks('grunt-contrib-jshint'); |
| 104 | + grunt.loadNpmTasks('grunt-contrib-uglify'); |
| 105 | + grunt.loadNpmTasks('grunt-contrib-qunit'); |
| 106 | + grunt.loadNpmTasks('grunt-contrib-watch'); |
| 107 | + grunt.loadNpmTasks('grunt-recess'); |
| 108 | + |
| 109 | + |
| 110 | + // Test task. |
| 111 | + grunt.registerTask('test', ['jshint', 'qunit']); |
| 112 | + |
| 113 | + // JS distribution task. |
| 114 | + grunt.registerTask('dist-js', ['concat', 'uglify']); |
| 115 | + |
| 116 | + // CSS distribution task. |
| 117 | + grunt.registerTask('dist-css', ['recess']); |
| 118 | + |
| 119 | + // Full distribution task. |
| 120 | + grunt.registerTask('dist', ['clean', 'dist-css', 'dist-js']); |
| 121 | + |
| 122 | + // Default task. |
| 123 | + grunt.registerTask('default', ['test', 'dist']); |
| 124 | +}; |
0 commit comments