Gruntfile.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. module.exports = function (grunt) {
  2. grunt.initConfig({
  3. pkg: grunt.file.readJSON('package.json'),
  4. cssmin: {
  5. wui: {
  6. expand: true,
  7. cwd: 'src/wui',
  8. src: ['*.css', '!*.min.css'],
  9. dest: 'src/wui',
  10. ext: '.min.css'
  11. },
  12. upload: {
  13. expand: true,
  14. cwd: 'src/upload',
  15. src: ['*.css', '!*.min.css'],
  16. dest: 'src/upload',
  17. ext: '.min.css'
  18. }
  19. },
  20. uglify: {
  21. wui: {
  22. files: {
  23. 'src/wui/main.min.js': ['src/wui/main.js'],
  24. 'src/wui/role.min.js': ['src/wui/role.js']
  25. }
  26. },
  27. upload: {
  28. files: {
  29. 'src/upload/upload.min.js': ['src/upload/upload.js']
  30. }
  31. }
  32. },
  33. compress: {
  34. wui: {
  35. options: {
  36. mode: 'gzip'
  37. },
  38. files: [
  39. {expand: true, cwd: 'src/wui/',src: ['*.min.js'], dest: 'dist/wui', ext: '.js'},
  40. {expand: true, cwd: 'src/wui/',src: ['*.min.css'], dest: 'dist/wui', ext: '.css'},
  41. {expand: true, cwd: 'src/wui/',src: ['*.min.html'], dest: 'dist/wui', ext: '.html'}
  42. ]
  43. },
  44. upload: {
  45. options: {
  46. mode: 'gzip'
  47. },
  48. files: [
  49. {expand: true, cwd: 'src/upload/',src: ['*.min.js'], dest: 'dist/upload', ext: '.js'},
  50. {expand: true, cwd: 'src/upload/',src: ['*.min.css'], dest: 'dist/upload', ext: '.css'},
  51. {expand: true, cwd: 'src/upload/',src: ['*.html'], dest: 'dist/upload', ext: '.html'}
  52. ]
  53. }
  54. },
  55. htmlmin: {
  56. wui: {
  57. options: {
  58. removeComments: true,
  59. collapseWhitespace: true,
  60. minifyJS : true
  61. },
  62. files: {
  63. 'src/wui/login.min.html': 'src/wui/login.html',
  64. 'src/wui/index.min.html': 'src/wui/index.html',
  65. 'src/wui/settings.min.html': 'src/wui/settings.html',
  66. 'src/wui/info.min.html': 'src/wui/info.html',
  67. 'src/wui/history.min.html': 'src/wui/history.html',
  68. 'src/wui/ups_history.min.html': 'src/wui/ups_history.html'
  69. }
  70. },
  71. upload: {
  72. options: {
  73. removeComments: true,
  74. collapseWhitespace: true,
  75. minifyJS : true
  76. },
  77. files: {
  78. 'dist/upload/index.html': 'src/upload/index.html',
  79. 'dist/upload/error.html': 'src/upload/error.html',
  80. 'dist/upload/success.html': 'src/upload/success.html'
  81. }
  82. }
  83. },
  84. imagemin: {
  85. wui:{
  86. options: {
  87. optimizationLevel: 0
  88. },
  89. files: [
  90. {'dist/wui/rotek.png': 'src/wui/rotek.png'},
  91. {'dist/wui/favicon.ico': 'src/wui/favicon.ico'},
  92. {'dist/upload/favicon.ico': 'src/upload/favicon.ico'}
  93. ]
  94. }
  95. },
  96. clean: {
  97. wui: {
  98. src: ['src/wui/main.min.js', 'src/wui/*.min.html', '!src/wui/main.js', 'src/wui/role.min.js', '!src/wui/role.js', 'src/wui/main.min.css', '!src/wui/main.css']
  99. },
  100. upload: {
  101. src: ['src/upload/upload.min.js', '!src/upload/upload.js', 'src/upload/upload.min.css', '!src/upload/upload.css']
  102. },
  103. clear: {
  104. src: 'dist*/*'
  105. }
  106. },
  107. jshint: {
  108. all: ['Gruntfile.js', 'src/wui/main.js', 'src/upload/upload.js']
  109. }
  110. });
  111. grunt.loadNpmTasks('grunt-contrib-htmlmin');
  112. grunt.loadNpmTasks('grunt-contrib-uglify');
  113. grunt.loadNpmTasks('grunt-contrib-cssmin');
  114. grunt.loadNpmTasks('grunt-contrib-clean');
  115. grunt.loadNpmTasks('grunt-contrib-compress');
  116. grunt.loadNpmTasks('grunt-contrib-imagemin');
  117. grunt.loadNpmTasks('grunt-contrib-jshint');
  118. grunt.registerTask('default', ['cssmin','uglify','htmlmin','clean:wui','clean:upload']);
  119. grunt.registerTask('build', ['cssmin','uglify','htmlmin','compress','clean:wui','clean:upload','imagemin']);
  120. grunt.registerTask('clear', ['clean:clear']);
  121. grunt.registerTask('jhint', ['jshint']);
  122. };