Gruntfile.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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/rslogin.min.html': 'src/wui/rslogin.html',
  65. 'src/wui/index.min.html': 'src/wui/index.html',
  66. 'src/wui/settings.min.html': 'src/wui/settings.html',
  67. 'src/wui/info.min.html': 'src/wui/info.html',
  68. 'src/wui/history.min.html': 'src/wui/history.html',
  69. 'src/wui/ups_history.min.html': 'src/wui/ups_history.html'
  70. }
  71. },
  72. upload: {
  73. options: {
  74. removeComments: true,
  75. collapseWhitespace: true,
  76. minifyJS : true
  77. },
  78. files: {
  79. 'dist/upload/index.html': 'src/upload/index.html',
  80. 'dist/upload/error.html': 'src/upload/error.html',
  81. 'dist/upload/success.html': 'src/upload/success.html'
  82. }
  83. }
  84. },
  85. imagemin: {
  86. wui:{
  87. options: {
  88. optimizationLevel: 0
  89. },
  90. files: [
  91. {'dist/wui/rotek.png': 'src/wui/rotek.png'},
  92. {'dist/wui/favicon.ico': 'src/wui/favicon.ico'},
  93. {'dist/upload/favicon.ico': 'src/upload/favicon.ico'}
  94. ]
  95. }
  96. },
  97. clean: {
  98. wui: {
  99. 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']
  100. },
  101. upload: {
  102. src: ['src/upload/upload.min.js', '!src/upload/upload.js', 'src/upload/upload.min.css', '!src/upload/upload.css']
  103. },
  104. clear: {
  105. src: 'dist*/*'
  106. }
  107. },
  108. jshint: {
  109. all: ['Gruntfile.js', 'src/wui/main.js', 'src/upload/upload.js']
  110. }
  111. });
  112. grunt.loadNpmTasks('grunt-contrib-htmlmin');
  113. grunt.loadNpmTasks('grunt-contrib-uglify');
  114. grunt.loadNpmTasks('grunt-contrib-cssmin');
  115. grunt.loadNpmTasks('grunt-contrib-clean');
  116. grunt.loadNpmTasks('grunt-contrib-compress');
  117. grunt.loadNpmTasks('grunt-contrib-imagemin');
  118. grunt.loadNpmTasks('grunt-contrib-jshint');
  119. grunt.registerTask('default', ['cssmin','uglify','htmlmin','clean:wui','clean:upload']);
  120. grunt.registerTask('build', ['cssmin','uglify','htmlmin','compress','clean:wui','clean:upload','imagemin']);
  121. grunt.registerTask('clear', ['clean:clear']);
  122. grunt.registerTask('jhint', ['jshint']);
  123. };