Gruntfile.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. module.exports = function (grunt) {
  2. grunt.initConfig({
  3. pkg: grunt.file.readJSON('package.json'),
  4. cssmin: {
  5. 'wui-3': {
  6. expand: true,
  7. cwd: 'src/wui-3',
  8. src: ['*.css', '!*.min.css'],
  9. dest: 'src/wui-3',
  10. ext: '.min.css'
  11. },
  12. 'wui-7': {
  13. expand: true,
  14. cwd: 'src/wui-7',
  15. src: ['*.css', '!*.min.css'],
  16. dest: 'src/wui-7',
  17. ext: '.min.css'
  18. },
  19. 'wui-9': {
  20. expand: true,
  21. cwd: 'src/wui-9',
  22. src: ['*.css', '!*.min.css'],
  23. dest: 'src/wui-9',
  24. ext: '.min.css'
  25. },
  26. upload: {
  27. expand: true,
  28. cwd: 'src/upload',
  29. src: ['*.css', '!*.min.css'],
  30. dest: 'src/upload',
  31. ext: '.min.css'
  32. }
  33. },
  34. uglify: {
  35. 'wui-3': {
  36. files: [{
  37. expand: true,
  38. cwd: 'src/wui-3',
  39. src: '**/*.js',
  40. dest: 'src/wui-3',
  41. rename: function (dst, src) {
  42. return dst + '/' + src.replace('.js', '.min.js');
  43. }
  44. }]
  45. },
  46. 'wui-7': {
  47. files: [{
  48. expand: true,
  49. cwd: 'src/wui-7',
  50. src: '**/*.js',
  51. dest: 'src/wui-7',
  52. rename: function (dst, src) {
  53. return dst + '/' + src.replace('.js', '.min.js');
  54. }
  55. }]
  56. },
  57. 'wui-9': {
  58. files: [{
  59. expand: true,
  60. cwd: 'src/wui-9',
  61. src: '**/*.js',
  62. dest: 'src/wui-9',
  63. rename: function (dst, src) {
  64. return dst + '/' + src.replace('.js', '.min.js');
  65. }
  66. }]
  67. },
  68. upload: {
  69. files: [{
  70. expand: true,
  71. cwd: 'src/upload',
  72. src: '**/*.js',
  73. dest: 'src/upload',
  74. rename: function (dst, src) {
  75. return dst + '/' + src.replace('.js', '.min.js');
  76. }
  77. }]
  78. }
  79. },
  80. compress: {
  81. 'wui-3': {
  82. options: { mode: 'gzip' },
  83. files: [
  84. {expand: true, cwd: 'src/wui-3/',src: ['*.min.js'], dest: 'dist/wui-3', ext: '.js'},
  85. {expand: true, cwd: 'src/wui-3/',src: ['*.min.css'], dest: 'dist/wui-3', ext: '.css'},
  86. {expand: true, cwd: 'src/wui-3/',src: ['*.min.html'], dest: 'dist/wui-3', ext: '.html'}
  87. ]
  88. },
  89. 'wui-6': {
  90. options: { mode: 'gzip' },
  91. files: [
  92. {expand: true, cwd: 'src/wui-7/',src: ['*.min.js'], dest: 'dist/wui-7', ext: '.js'},
  93. {expand: true, cwd: 'src/wui-7/',src: ['*.min.css'], dest: 'dist/wui-7', ext: '.css'},
  94. {expand: true, cwd: 'src/wui-7/',src: ['*.min.html'], dest: 'dist/wui-7', ext: '.html'}
  95. ]
  96. },
  97. 'wui-8': {
  98. options: { mode: 'gzip' },
  99. files: [
  100. {expand: true, cwd: 'src/wui-9/',src: ['*.min.js'], dest: 'dist/wui-9', ext: '.js'},
  101. {expand: true, cwd: 'src/wui-9/',src: ['*.min.css'], dest: 'dist/wui-9', ext: '.css'},
  102. {expand: true, cwd: 'src/wui-9/',src: ['*.min.html'], dest: 'dist/wui-9', ext: '.html'}
  103. ]
  104. },
  105. upload: {
  106. options: { mode: 'gzip' },
  107. files: [
  108. {expand: true, cwd: 'src/upload/',src: ['*.min.js'], dest: 'dist/upload', ext: '.js'},
  109. {expand: true, cwd: 'src/upload/',src: ['*.min.css'], dest: 'dist/upload', ext: '.css'},
  110. {expand: true, cwd: 'src/upload/',src: ['*.html'], dest: 'dist/upload', ext: '.html'}
  111. ]
  112. }
  113. },
  114. htmlmin: {
  115. 'wui-3': {
  116. options: { removeComments: true, collapseWhitespace: true },
  117. files: [{
  118. expand: true,
  119. cwd: 'src/wui-3',
  120. src: ['*.html'],
  121. dest: 'src/wui-3',
  122. rename: function (dst, src) {
  123. return dst + '/' + src.replace('.html', '.min.html');
  124. }
  125. }]
  126. },
  127. 'wui-7': {
  128. options: { removeComments: true, collapseWhitespace: true },
  129. files: [{
  130. expand: true,
  131. cwd: 'src/wui-7',
  132. src: ['*.html'],
  133. dest: 'src/wui-7',
  134. rename: function (dst, src) {
  135. return dst + '/' + src.replace('.html', '.min.html');
  136. }
  137. }]
  138. },
  139. 'wui-9': {
  140. options: { removeComments: true, collapseWhitespace: true },
  141. files: [{
  142. expand: true,
  143. cwd: 'src/wui-9',
  144. src: ['*.html'],
  145. dest: 'src/wui-9',
  146. rename: function (dst, src) {
  147. return dst + '/' + src.replace('.html', '.min.html');
  148. }
  149. }]
  150. },
  151. upload: {
  152. options: { removeComments: true, collapseWhitespace: true },
  153. files: [{
  154. expand: true,
  155. cwd: 'src/upload',
  156. src: ['*.html'],
  157. dest: 'src/upload',
  158. rename: function (dst, src) {
  159. return dst + '/' + src.replace('.html', '.min.html');
  160. }
  161. }]
  162. }
  163. },
  164. imagemin: {
  165. 'wui-3':{
  166. options: { optimizationLevel: 0 },
  167. files: [
  168. {'dist/wui-3/rotek.png': 'src/wui-3/rotek.png'},
  169. {'dist/wui-3/favicon.ico': 'src/wui-3/favicon.ico'}
  170. ]
  171. },
  172. 'wui-7':{
  173. options: { optimizationLevel: 0 },
  174. files: [
  175. {'dist/wui-7/rotek.png': 'src/wui-7/rotek.png'},
  176. {'dist/wui-7/favicon.ico': 'src/wui-7/favicon.ico'}
  177. ]
  178. },
  179. 'wui-9':{
  180. options: { optimizationLevel: 0 },
  181. files: [
  182. {'dist/wui-9/rotek.png': 'src/wui-9/rotek.png'},
  183. {'dist/wui-9/favicon.ico': 'src/wui-9/favicon.ico'}
  184. ]
  185. },
  186. upload:{
  187. options: { optimizationLevel: 0 },
  188. files: [
  189. {'dist/upload/favicon.ico': 'src/upload/favicon.ico'}
  190. ]
  191. }
  192. },
  193. clean: {
  194. all: {
  195. src: [
  196. '!src/**/*.js',
  197. '!src/**/*.css',
  198. 'src/**/*.min.js',
  199. 'src/**/*.min.css',
  200. 'src/**/*.min.html'
  201. ]
  202. },
  203. clear: {
  204. src: 'dist*/*'
  205. }
  206. },
  207. jshint: {
  208. all: ['Gruntfile.js', 'src/**/*.js']
  209. }
  210. });
  211. grunt.loadNpmTasks('grunt-contrib-htmlmin');
  212. grunt.loadNpmTasks('grunt-contrib-uglify');
  213. grunt.loadNpmTasks('grunt-contrib-cssmin');
  214. grunt.loadNpmTasks('grunt-contrib-clean');
  215. grunt.loadNpmTasks('grunt-contrib-compress');
  216. grunt.loadNpmTasks('grunt-contrib-imagemin');
  217. grunt.loadNpmTasks('grunt-contrib-jshint');
  218. grunt.registerTask('default', ['cssmin','uglify','htmlmin','clean:all']);
  219. grunt.registerTask('build', ['cssmin','uglify','htmlmin','compress','clean:all', 'imagemin']);
  220. grunt.registerTask('clear', ['clean:clear']);
  221. grunt.registerTask('jhint', ['jshint']);
  222. };