Gruntfile.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. }
  25. },
  26. upload: {
  27. files: {
  28. 'src/upload/upload.min.js': ['src/upload/upload.js']
  29. }
  30. }
  31. },
  32. compress: {
  33. wui: {
  34. options: {
  35. mode: 'gzip'
  36. },
  37. files: [
  38. {expand: true, cwd: 'src/wui/',src: ['*.min.js'], dest: 'dist/wui', ext: '.js'},
  39. {expand: true, cwd: 'src/wui/',src: ['*.min.css'], dest: 'dist/wui', ext: '.css'},
  40. {expand: true, cwd: 'src/wui/',src: ['*.min.html'], dest: 'dist/wui', ext: '.html'}
  41. ]
  42. },
  43. upload: {
  44. options: {
  45. mode: 'gzip'
  46. },
  47. files: [
  48. {expand: true, cwd: 'src/upload/',src: ['*.min.js'], dest: 'dist/upload', ext: '.js'},
  49. {expand: true, cwd: 'src/upload/',src: ['*.min.css'], dest: 'dist/upload', ext: '.css'},
  50. {expand: true, cwd: 'src/upload/',src: ['*.html'], dest: 'dist/upload', ext: '.html'}
  51. ]
  52. }
  53. },
  54. htmlmin: {
  55. wui: {
  56. options: {
  57. removeComments: true,
  58. collapseWhitespace: true,
  59. minifyJS : true
  60. },
  61. files: {
  62. 'src/wui/index.min.html': 'src/wui/index.html',
  63. 'src/wui/settings.min.html': 'src/wui/settings.html',
  64. 'src/wui/info.min.html': 'src/wui/info.html'
  65. }
  66. },
  67. upload: {
  68. options: {
  69. removeComments: true,
  70. collapseWhitespace: true,
  71. minifyJS : true
  72. },
  73. files: {
  74. 'dist/upload/index.html': 'src/upload/index.html',
  75. 'dist/upload/error.html': 'src/upload/error.html',
  76. 'dist/upload/success.html': 'src/upload/success.html'
  77. }
  78. }
  79. },
  80. imagemin: {
  81. wui:{
  82. options: {
  83. optimizationLevel: 0
  84. },
  85. files: [
  86. {'dist/wui/rotek.png': 'src/wui/rotek.png'},
  87. {'dist/wui/favicon.ico': 'src/wui/favicon.ico'},
  88. {'dist/upload/favicon.ico': 'src/upload/favicon.ico'}
  89. ]
  90. }
  91. },
  92. clean: {
  93. wui: {
  94. src: ["src/wui/main.min.js", "src/wui/*.min.html", "!src/wui/main.js", "src/wui/main.min.css", "!src/wui/main.css"]
  95. },
  96. upload: {
  97. src: ["src/upload/upload.min.js", "!src/upload/upload.js", "src/upload/upload.min.css", "!src/upload/upload.css"]
  98. },
  99. clear: {
  100. src: 'dist*/*'
  101. }
  102. },
  103. jshint: {
  104. all: ['Gruntfile.js', 'src/wui/main.js', 'src/upload/upload.js']
  105. }
  106. });
  107. grunt.loadNpmTasks('grunt-contrib-htmlmin');
  108. grunt.loadNpmTasks('grunt-contrib-uglify');
  109. grunt.loadNpmTasks('grunt-contrib-cssmin');
  110. grunt.loadNpmTasks('grunt-contrib-clean');
  111. grunt.loadNpmTasks('grunt-contrib-compress');
  112. grunt.loadNpmTasks('grunt-contrib-imagemin');
  113. grunt.loadNpmTasks('grunt-contrib-jshint');
  114. grunt.registerTask('default', ['cssmin','uglify','htmlmin','clean:wui','clean:upload']);
  115. grunt.registerTask('build', ['cssmin','uglify','htmlmin','compress','clean:wui','clean:upload','imagemin']);
  116. grunt.registerTask('clear', ['clean:clear']);
  117. grunt.registerTask('jhint', ['jshint']);
  118. };