Gruntfile.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. module.exports = function (grunt) {
  2. // Full list of files that must be included by RequireJS
  3. includes = [
  4. 'jquery.select2'
  5. ];
  6. amdIncludes = [
  7. 'almond'
  8. ];
  9. fullIncludes = [
  10. 'jquery'
  11. ].concat(includes);
  12. grunt.initConfig({
  13. uglify: {
  14. 'dist': {
  15. src: 'dist/js/select2.js',
  16. dest: 'dist/js/select2.min.js'
  17. },
  18. 'dist.full': {
  19. src: 'dist/js/select2.full.js',
  20. dest: 'dist/js/select2.full.min.js'
  21. }
  22. },
  23. qunit: {
  24. all: [
  25. 'tests/**/*.html'
  26. ]
  27. },
  28. jshint: {
  29. options: {
  30. jshintrc: true
  31. },
  32. code: {
  33. src: ['src/js/**/*.js']
  34. },
  35. tests: {
  36. src: ['tests/**/*.js']
  37. }
  38. },
  39. sass: {
  40. dist: {
  41. options: {
  42. outputStyle: 'compressed'
  43. },
  44. files: {
  45. 'dist/css/select2.min.css': [
  46. 'src/scss/core.scss',
  47. 'src/scss/theme/default/layout.css'
  48. ]
  49. }
  50. },
  51. dev: {
  52. options: {
  53. outputStyle: 'nested'
  54. },
  55. files: {
  56. 'dist/css/select2.css': [
  57. 'src/scss/core.scss',
  58. 'src/scss/theme/default/layout.css'
  59. ]
  60. }
  61. }
  62. },
  63. requirejs: {
  64. 'dist': {
  65. options: {
  66. baseUrl: 'src/js',
  67. optimize: 'none',
  68. name: 'select2/core',
  69. out: 'dist/js/select2.js',
  70. include: amdIncludes.concat(includes),
  71. paths: {
  72. almond: '../../vendor/almond-0.2.9',
  73. jquery: 'jquery.shim'
  74. },
  75. wrap: grunt.file.readJSON('src/js/banner.json')
  76. }
  77. },
  78. 'dist.full': {
  79. options: {
  80. baseUrl: 'src/js',
  81. optimize: 'none',
  82. name: 'select2/core',
  83. out: 'dist/js/select2.full.js',
  84. include: amdIncludes.concat(fullIncludes),
  85. paths: {
  86. almond: '../../vendor/almond-0.2.9',
  87. jquery: '../../vendor/jquery-2.1.0'
  88. },
  89. wrap: grunt.file.readJSON('src/js/banner.json')
  90. }
  91. },
  92. 'amd': {
  93. options: {
  94. baseUrl: 'src/js',
  95. optimize: 'none',
  96. name: 'select2/core',
  97. out: 'dist/js/select2.amd.js',
  98. include: includes,
  99. paths: {
  100. jquery: 'empty:'
  101. },
  102. wrap: grunt.file.readJSON('src/js/banner.json')
  103. }
  104. },
  105. 'amd.full': {
  106. options: {
  107. baseUrl: 'src/js',
  108. optimize: 'none',
  109. name: 'select2/core',
  110. out: 'dist/js/select2.amd.full.js',
  111. include: fullIncludes,
  112. paths: {
  113. jquery: 'empty:'
  114. },
  115. wrap: grunt.file.readJSON('src/js/banner.json')
  116. }
  117. }
  118. },
  119. watch: {
  120. js: {
  121. files: [
  122. 'src/js/select2/**/*.js',
  123. 'tests/**/*.js'
  124. ],
  125. tasks: [
  126. 'compile',
  127. 'test',
  128. 'minify'
  129. ]
  130. },
  131. css: {
  132. files: [
  133. 'src/scss/**/*.scss'
  134. ],
  135. tasks: [
  136. 'compile',
  137. 'minify'
  138. ]
  139. }
  140. }
  141. });
  142. grunt.loadNpmTasks('grunt-contrib-concat');
  143. grunt.loadNpmTasks('grunt-contrib-jshint');
  144. grunt.loadNpmTasks('grunt-contrib-qunit');
  145. grunt.loadNpmTasks('grunt-contrib-requirejs');
  146. grunt.loadNpmTasks('grunt-contrib-uglify');
  147. grunt.loadNpmTasks('grunt-contrib-watch');
  148. grunt.loadNpmTasks('grunt-sass');
  149. grunt.registerTask('default', ['compile', 'test', 'minify']);
  150. grunt.registerTask('compile', ['requirejs', 'sass:dev']);
  151. grunt.registerTask('minify', ['uglify', 'sass:dist']);
  152. grunt.registerTask('test', ['qunit', 'jshint']);
  153. };