Gruntfile.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. 'use strict';
  2. module.exports = function(grunt) {
  3. grunt.initConfig({
  4. concat: {
  5. options: {
  6. sourceMap: true
  7. },
  8. dist: {
  9. dest: 'dist/jsoneditor.js',
  10. src: [
  11. // License & version info, start the containing closure
  12. 'src/intro.js',
  13. // Simple inheritance
  14. 'src/class.js',
  15. // IE9 polyfills
  16. 'src/ie9.js',
  17. // Utils like extend, each, and trigger
  18. 'src/utilities.js',
  19. // The main JSONEditor class
  20. 'src/core.js',
  21. // JSON Schema validator
  22. 'src/validator.js',
  23. // All the editors
  24. 'src/editor.js',
  25. 'src/editors/null.js',
  26. 'src/editors/string.js',
  27. 'src/editors/hidden.js',
  28. 'src/editors/number.js',
  29. 'src/editors/integer.js',
  30. 'src/editors/rating.js',
  31. 'src/editors/object.js',
  32. 'src/editors/array.js',
  33. 'src/editors/table.js',
  34. 'src/editors/multiple.js',
  35. 'src/editors/enum.js',
  36. 'src/editors/select.js',
  37. 'src/editors/selectize.js',
  38. 'src/editors/multiselect.js',
  39. 'src/editors/base64.js',
  40. 'src/editors/upload.js',
  41. 'src/editors/checkbox.js',
  42. 'src/editors/array/selectize.js',
  43. // All the themes and iconlibs
  44. 'src/theme.js',
  45. 'src/themes/*.js',
  46. 'src/iconlib.js',
  47. 'src/iconlibs/*.js',
  48. // The JS templating engines
  49. 'src/templates/*.js',
  50. // Set the defaults
  51. 'src/defaults.js',
  52. // Wrapper for $.fn style initialization
  53. 'src/jquery.js',
  54. // End the closure
  55. 'src/outro.js'
  56. ],
  57. }
  58. },
  59. uglify: {
  60. dist: {
  61. src: 'dist/jsoneditor.js',
  62. dest: 'dist/jsoneditor.min.js'
  63. },
  64. options: {
  65. preserveComments: 'some',
  66. sourceMap: true
  67. }
  68. },
  69. watch: {
  70. scripts: {
  71. files: ["src/**/*.js"],
  72. tasks: ["concat"]
  73. }
  74. },
  75. jshint: {
  76. options: {
  77. browser: true,
  78. indent: 2,
  79. devel:true,
  80. nonbsp: true,
  81. nonew: true,
  82. immed: true,
  83. latedef: true
  84. },
  85. beforeconcat: [
  86. 'src/class.js',
  87. 'src/ie9.js',
  88. // Utils like extend, each, and trigger
  89. 'src/utilities.js',
  90. // The main JSONEditor class
  91. 'src/core.js',
  92. // JSON Schema validator
  93. 'src/validator.js',
  94. // All the editors
  95. 'src/editor.js',
  96. 'src/editors/*.js',
  97. // All the themes and iconlibs
  98. 'src/theme.js',
  99. 'src/themes/*.js',
  100. 'src/iconlib.js',
  101. 'src/iconlibs/*.js',
  102. // The JS templating engines
  103. 'src/templates/*.js',
  104. // Set the defaults
  105. 'src/defaults.js',
  106. // Wrapper for $.fn style initialization
  107. 'src/jquery.js'
  108. ],
  109. afterconcat: {
  110. options: {
  111. undef: true
  112. },
  113. files: {
  114. src: ['dist/jsoneditor.js']
  115. }
  116. }
  117. },
  118. connect: {
  119. default: {
  120. options: {
  121. port: 9000,
  122. hostname: '0.0.0.0',
  123. debug: true,
  124. keepalive: true
  125. }
  126. },
  127. testing: {
  128. options: {
  129. port: 9001,
  130. hostname: '0.0.0.0',
  131. debug: true,
  132. keepalive: true
  133. }
  134. }
  135. },
  136. run: {
  137. options: {
  138. // Task-specific options
  139. },
  140. mocha: {
  141. cmd: 'mocha',
  142. args: [
  143. 'tests/selenium/*.js',
  144. '--reporter=nyan'
  145. ]
  146. }
  147. }
  148. });
  149. // These plugins provide necessary tasks.
  150. grunt.loadNpmTasks('grunt-contrib-uglify');
  151. grunt.loadNpmTasks('grunt-contrib-watch');
  152. grunt.loadNpmTasks('grunt-contrib-jshint');
  153. grunt.loadNpmTasks('grunt-contrib-concat');
  154. grunt.loadNpmTasks('grunt-contrib-connect');
  155. grunt.loadNpmTasks('grunt-run');
  156. // Serve files
  157. grunt.registerTask('serve', 'connect:default');
  158. grunt.registerTask('serve-test', 'connect:testing');
  159. // Run mocha tests
  160. grunt.registerTask('test', ['run:mocha']);
  161. // Default task.
  162. grunt.registerTask('default', ['jshint:beforeconcat','concat','jshint:afterconcat','uglify']);
  163. grunt.registerTask('rawbuild', ['concat','uglify']);
  164. };