| 1 | module.exports = function(grunt) { |
| 2 | |
| 3 | grunt.initConfig({ |
| 4 | |
| 5 | pkg: grunt.file.readJSON('package.json'), |
| 6 | |
| 7 | lint: { |
| 8 | all: ['backbone.stickit.js'] |
| 9 | }, |
| 10 | |
| 11 | jshint: { |
| 12 | src: ['backbone.stickit.js'], |
| 13 | options: { |
| 14 | browser: true, |
| 15 | indent: 2, |
| 16 | white: false, |
| 17 | evil: true, |
| 18 | regexdash: true, |
| 19 | wsh: true, |
| 20 | trailing: true, |
| 21 | eqnull: true, |
| 22 | expr: true, |
| 23 | boss: true, |
| 24 | node: true, |
| 25 | strict: false |
| 26 | } |
| 27 | }, |
| 28 | |
| 29 | qunit: { |
| 30 | all: { |
| 31 | options: { |
| 32 | urls: ['http://localhost:3000/test/index.html'] |
| 33 | } |
| 34 | } |
| 35 | }, |
| 36 | |
| 37 | server: { |
| 38 | port: 8000, |
| 39 | base: '.' |
| 40 | }, |
| 41 | |
| 42 | concat: { |
| 43 | options: { |
| 44 | stripBanners: true, |
| 45 | banner: '//\n' + |
| 46 | '// <%= pkg.name %> - v<%= pkg.version %>\n' + |
| 47 | '// The MIT License\n' + |
| 48 | '// Copyright (c) 2012 The New York Times, CMS Group, Matthew DeLambo <[email protected]> \n' + |
| 49 | '//\n' |
| 50 | }, |
| 51 | dist: { |
| 52 | src: 'backbone.stickit.js', |
| 53 | dest: 'dist/backbone.stickit.js' |
| 54 | } |
| 55 | }, |
| 56 | |
| 57 | uglify: { |
| 58 | options: { |
| 59 | banner: '//\n' + |
| 60 | '// <%= pkg.name %> - v<%= pkg.version %>\n' + |
| 61 | '// The MIT License\n' + |
| 62 | '// Copyright (c) 2012 The New York Times, CMS Group, Matthew DeLambo <[email protected]> \n' + |
| 63 | '//\n' |
| 64 | }, |
| 65 | nasty: { |
| 66 | options: { |
| 67 | preserveComments: false |
| 68 | }, |
| 69 | files: { |
| 70 | 'dist/backbone.stickit.min.js': ['backbone.stickit.js'] |
| 71 | } |
| 72 | } |
| 73 | }, |
| 74 | |
| 75 | docco: { |
| 76 | app: { |
| 77 | src: ['dist/backbone.stickit.js'], |
| 78 | dest: "docs/" |
| 79 | } |
| 80 | }, |
| 81 | |
| 82 | compress: { |
| 83 | gz: { |
| 84 | options: { |
| 85 | mode: 'gzip' |
| 86 | }, |
| 87 | expand: true, |
| 88 | cwd: 'dist/', |
| 89 | src: ['backbone.stickit.min.js'], |
| 90 | dest: 'dist/' |
| 91 | }, |
| 92 | zip: { |
| 93 | options: { |
| 94 | archive: 'dist/backbone.stickit_<%= pkg.version %>.zip' |
| 95 | }, |
| 96 | files: [ |
| 97 | {src: './**', cwd: 'dist/', expand:true} |
| 98 | ] |
| 99 | } |
| 100 | }, |
| 101 | |
| 102 | clean: { |
| 103 | build: ['dist'], |
| 104 | docco: ['docs'] |
| 105 | } |
| 106 | }); |
| 107 | |
| 108 | grunt.loadNpmTasks('grunt-docco'); |
| 109 | grunt.loadNpmTasks('grunt-contrib-concat'); |
| 110 | grunt.loadNpmTasks('grunt-contrib-jshint'); |
| 111 | grunt.loadNpmTasks('grunt-contrib-qunit'); |
| 112 | grunt.loadNpmTasks('grunt-contrib-uglify'); |
| 113 | grunt.loadNpmTasks('grunt-contrib-clean'); |
| 114 | grunt.loadNpmTasks('grunt-contrib-compress'); |
| 115 | |
| 116 | grunt.registerTask('build', ['jshint', 'clean:build', 'uglify:nasty', 'concat', 'compress:gz', 'cp-docs', 'compress:zip']); |
| 117 | |
| 118 | grunt.registerTask('cp-docs', function() { |
| 119 | grunt.file.copy('docs/docco.css', 'dist/docs/annotated/docco.css'); |
| 120 | grunt.file.copy('docs/backbone.stickit.html', 'dist/docs/annotated/index.html'); |
| 121 | }); |
| 122 | |
| 123 | }; |