Gruntfile.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*global module:false*/
  2. module.exports = function(grunt) {
  3. var banner = '/*!\n' +
  4. ' * ====================================================\n' +
  5. ' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
  6. '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
  7. '<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
  8. ' * GitHub: <%= pkg.repository.url %> \n' +
  9. ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
  10. ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n' +
  11. ' * ====================================================\n' +
  12. ' */\n\n';
  13. // Project configuration.
  14. grunt.initConfig({
  15. // Metadata.
  16. pkg: grunt.file.readJSON('package.json'),
  17. dependence: {
  18. options: {
  19. entrance: 'kity',
  20. base: 'src'
  21. },
  22. merge: {
  23. files: [{
  24. src: 'src/**/*.js',
  25. dest: '.build_tmp/kity_tmp.js'
  26. }]
  27. }
  28. },
  29. concat: {
  30. closure: {
  31. options: {
  32. banner: banner + '(function () {\n',
  33. footer: '})();'
  34. },
  35. files: {
  36. 'dist/kity.js': ['.build_tmp/kity_tmp.js', 'dev-lib/exports.js']
  37. }
  38. }
  39. },
  40. uglify: {
  41. options: {
  42. banner: banner
  43. },
  44. minimize: {
  45. files: {
  46. 'dist/kity.min.js': 'dist/kity.js'
  47. }
  48. }
  49. },
  50. clean: {
  51. tmp: ['.build_tmp']
  52. },
  53. jasmine: {
  54. unit: {
  55. src: ['dist/kity.min.js'],
  56. options: {
  57. specs: [
  58. 'spec/core/*',
  59. 'spec/graphic/*'
  60. ],
  61. helpers: 'spec/SpecHelper.js',
  62. host: 'http://127.0.0.1:7777/'
  63. }
  64. }
  65. },
  66. connect: {
  67. unit: {
  68. options: {
  69. hostname: '0.0.0.0',
  70. port: 7777,
  71. base: '.'
  72. }
  73. }
  74. }
  75. });
  76. // These plugins provide necessary tasks.
  77. grunt.loadNpmTasks('grunt-module-dependence');
  78. grunt.loadNpmTasks('grunt-contrib-concat');
  79. grunt.loadNpmTasks('grunt-contrib-uglify');
  80. grunt.loadNpmTasks('grunt-contrib-clean');
  81. grunt.loadNpmTasks('grunt-contrib-connect');
  82. grunt.loadNpmTasks('grunt-contrib-jasmine');
  83. // Default task.
  84. grunt.registerTask('default', ['dependence:merge', 'concat:closure', 'uglify:minimize', 'clean:tmp']);
  85. grunt.registerTask('test', ['default', 'connect:unit', 'jasmine:unit']);
  86. };