Gruntfile.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. var expose = '\nuse(\'expose-kity\');\n';
  14. // Project configuration.
  15. grunt.initConfig({
  16. // Metadata.
  17. pkg: grunt.file.readJSON('package.json'),
  18. dependence: {
  19. options: {
  20. entrance: 'expose-kity',
  21. base: 'src'
  22. },
  23. merge: {
  24. files: [{
  25. src: 'src/**/*.js',
  26. dest: '.build_tmp/kity_tmp.js'
  27. }]
  28. }
  29. },
  30. concat: {
  31. closure: {
  32. options: {
  33. banner: banner + '(function () {\n',
  34. footer: expose + '})();'
  35. },
  36. files: {
  37. 'dist/kity.js': ['.build_tmp/kity_tmp.js']
  38. }
  39. }
  40. },
  41. uglify: {
  42. options: {
  43. banner: banner
  44. },
  45. minimize: {
  46. files: {
  47. 'dist/kity.min.js': 'dist/kity.js'
  48. }
  49. }
  50. },
  51. clean: {
  52. tmp: ['.build_tmp']
  53. },
  54. jasmine: {
  55. unit: {
  56. src: ['dist/kity.min.js'],
  57. options: {
  58. specs: [
  59. 'spec/core/*',
  60. 'spec/graphic/*'
  61. ],
  62. helpers: 'spec/SpecHelper.js',
  63. host: 'http://127.0.0.1:7777/'
  64. }
  65. }
  66. },
  67. connect: {
  68. unit: {
  69. options: {
  70. hostname: '0.0.0.0',
  71. port: 7777,
  72. base: '.'
  73. }
  74. }
  75. }
  76. });
  77. // These plugins provide necessary tasks.
  78. grunt.loadNpmTasks('grunt-module-dependence');
  79. grunt.loadNpmTasks('grunt-contrib-concat');
  80. grunt.loadNpmTasks('grunt-contrib-uglify');
  81. grunt.loadNpmTasks('grunt-contrib-clean');
  82. grunt.loadNpmTasks('grunt-contrib-connect');
  83. grunt.loadNpmTasks('grunt-contrib-jasmine');
  84. // Default task.
  85. grunt.registerTask('default', ['dependence:merge', 'concat:closure', 'uglify:minimize', 'clean:tmp']);
  86. grunt.registerTask('test', ['default', 'connect:unit', 'jasmine:unit']);
  87. };