Gruntfile.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. 'use strict';
  2. module.exports = function(grunt) {
  3. // Project configuration.
  4. grunt.initConfig({
  5. // Metadata.
  6. pkg: grunt.file.readJSON('jquery-ui-timepicker-addon.json'),
  7. banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
  8. //'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
  9. '<%= pkg.modified %>\n' +
  10. '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
  11. '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
  12. ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
  13. // Task configuration.
  14. clean: {
  15. files: ['dist']
  16. },
  17. copy: {
  18. dist: {
  19. files: [
  20. //{ src: 'src/index.html', dest: 'dist/index.html' },
  21. { src: 'src/<%= pkg.name %>.css', dest: 'dist/<%= pkg.name %>.css' },
  22. { src: 'src/jquery-ui-sliderAccess.js', dest: 'dist/jquery-ui-sliderAccess.js' },
  23. { src: 'src/i18n/jquery-ui-timepicker-*.js', dest: 'dist/i18n/', expand:true, flatten: true }
  24. ]
  25. }
  26. },
  27. concat: {
  28. dist: {
  29. options: {
  30. banner: '<%= banner %>',
  31. stripBanners: true
  32. },
  33. src: ['src/<%= pkg.name %>.js'],
  34. dest: 'dist/<%= pkg.name %>.js'
  35. },
  36. docs: {
  37. src: [
  38. 'src/docs/header.html',
  39. 'src/docs/intro.html',
  40. 'src/docs/options.html',
  41. 'src/docs/formatting.html',
  42. 'src/docs/i18n.html',
  43. 'src/docs/examples.html',
  44. 'src/docs/footer.html'
  45. ],
  46. dest: 'dist/index.html'
  47. },
  48. i18n: {
  49. options: {
  50. //stripBanners: true,
  51. banner: '<%=banner %>\n(function($){\n\n',
  52. footer: '\n})(jQuery);\n',
  53. process: function(src, filepath){
  54. return '// source: '+ filepath + '\n' +
  55. src.replace(/\(function\s*\(\$\)\s*\{/g, '')
  56. .replace(/\}\)\(jQuery\)\;/g, '')
  57. .replace(/\$\.timepicker\.setDefaults\(\$\.timepicker\.regional\[[a-z\-\'\"]+\]\)\;/gi, '')
  58. .trim() +'\n';
  59. }
  60. },
  61. src: [ 'src/i18n/jquery-ui-timepicker-*.js' ],
  62. dest: 'dist/i18n/<%=pkg.name %>-i18n.js'
  63. }
  64. },
  65. uglify: {
  66. options: {
  67. banner: '<%= banner %>'
  68. },
  69. dist: {
  70. src: '<%= concat.dist.dest %>',
  71. dest: 'dist/<%= pkg.name %>.min.js'
  72. },
  73. i18n: {
  74. src: 'dist/i18n/<%=pkg.name %>-i18n.js',
  75. dest: 'dist/i18n/<%=pkg.name %>-i18n.min.js'
  76. }
  77. },
  78. cssmin: {
  79. options: {
  80. banner: '<%= banner %>'
  81. },
  82. dist: {
  83. src: 'dist/<%= pkg.name %>.css',
  84. dest: 'dist/<%= pkg.name %>.min.css'
  85. }
  86. },
  87. replace: {
  88. dist: {
  89. options: {
  90. variables: {
  91. version: '<%= pkg.version %>',
  92. timestamp: '<%= pkg.modified %>'
  93. },
  94. prefix: '@@'
  95. },
  96. files: [
  97. { src: 'dist/<%= pkg.name %>.js', dest: 'dist/<%= pkg.name %>.js' },
  98. { src: 'dist/<%= pkg.name %>.css', dest: 'dist/<%= pkg.name %>.css' },
  99. { src: 'dist/index.html', dest: 'dist/index.html' }
  100. ]
  101. }
  102. },
  103. jasmine: {
  104. src: 'src/<%= pkg.name %>.js',
  105. options: {
  106. specs: 'test/*_spec.js',
  107. vendor: [
  108. 'http://code.jquery.com/jquery-1.11.1.min.js',
  109. 'http://code.jquery.com/ui/1.11.1/jquery-ui.min.js',
  110. 'http://github.com/searls/jasmine-fixture/releases/1.0.5/1737/jasmine-fixture.js'
  111. ]
  112. }
  113. },
  114. jshint: {
  115. gruntfile: {
  116. options: {
  117. jshintrc: '.jshintrc'
  118. },
  119. src: 'Gruntfile.js'
  120. },
  121. src: {
  122. options: {
  123. jshintrc: 'src/.jshintrc'
  124. },
  125. src: ['src/**/*.js']
  126. },
  127. test: {
  128. options: {
  129. jshintrc: 'test/.jshintrc'
  130. },
  131. src: ['test/**/*.js']
  132. }
  133. },
  134. watch: {
  135. gruntfile: {
  136. files: '<%= jshint.gruntfile.src %>',
  137. tasks: ['jshint:gruntfile']
  138. },
  139. src: {
  140. files: 'src/**',//'<%= jshint.src.src %>',
  141. tasks: ['jshint:src', 'jasmine', 'clean', 'copy', 'concat', 'replace', 'uglify', 'cssmin']
  142. //tasks: ['jshint:src', 'jasmine']
  143. },
  144. test: {
  145. files: '<%= jshint.test.src %>',
  146. tasks: ['jshint:test', 'jasmine']
  147. }
  148. }
  149. });
  150. // These plugins provide necessary tasks.
  151. grunt.loadNpmTasks('grunt-contrib-clean');
  152. grunt.loadNpmTasks('grunt-contrib-concat');
  153. grunt.loadNpmTasks('grunt-contrib-copy');
  154. grunt.loadNpmTasks('grunt-replace');
  155. grunt.loadNpmTasks('grunt-contrib-uglify');
  156. grunt.loadNpmTasks('grunt-contrib-cssmin');
  157. grunt.loadNpmTasks('grunt-contrib-jasmine');
  158. grunt.loadNpmTasks('grunt-contrib-jshint');
  159. grunt.loadNpmTasks('grunt-contrib-watch');
  160. // Default task.
  161. grunt.registerTask('default', ['clean', 'copy', 'concat', 'replace', 'uglify', 'cssmin']);
  162. // Test task.
  163. grunt.registerTask('test', ['jshint', 'jasmine']);
  164. };