Gruntfile.js 4.7 KB

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