Gruntfile.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. // AdminLTE Gruntfile
  2. module.exports = function (grunt) {
  3. 'use strict';
  4. grunt.initConfig({
  5. watch: {
  6. // If any .less file changes in directory "build/less/" run the "less"-task.
  7. files: ["build/less/*.less", "build/less/skins/*.less", "dist/js/app.js"],
  8. tasks: ["less", "uglify"]
  9. },
  10. // "less"-task configuration
  11. // This task will compile all less files upon saving to create both AdminLTE.css and AdminLTE.min.css
  12. less: {
  13. // Development not compressed
  14. development: {
  15. options: {
  16. // Whether to compress or not
  17. compress: false
  18. },
  19. files: {
  20. // compilation.css : source.less
  21. "dist/css/AdminLTE.css": "build/less/AdminLTE.less",
  22. //Non minified skin files
  23. "dist/css/skins/skin-blue.css": "build/less/skins/skin-blue.less",
  24. "dist/css/skins/skin-black.css": "build/less/skins/skin-black.less",
  25. "dist/css/skins/skin-yellow.css": "build/less/skins/skin-yellow.less",
  26. "dist/css/skins/skin-green.css": "build/less/skins/skin-green.less",
  27. "dist/css/skins/skin-red.css": "build/less/skins/skin-red.less",
  28. "dist/css/skins/skin-purple.css": "build/less/skins/skin-purple.less",
  29. "dist/css/skins/skin-blue-light.css": "build/less/skins/skin-blue-light.less",
  30. "dist/css/skins/skin-black-light.css": "build/less/skins/skin-black-light.less",
  31. "dist/css/skins/skin-yellow-light.css": "build/less/skins/skin-yellow-light.less",
  32. "dist/css/skins/skin-green-light.css": "build/less/skins/skin-green-light.less",
  33. "dist/css/skins/skin-red-light.css": "build/less/skins/skin-red-light.less",
  34. "dist/css/skins/skin-purple-light.css": "build/less/skins/skin-purple-light.less",
  35. "dist/css/skins/_all-skins.css": "build/less/skins/_all-skins.less"
  36. }
  37. },
  38. // Production compresses version
  39. production: {
  40. options: {
  41. // Whether to compress or not
  42. compress: true
  43. },
  44. files: {
  45. // compilation.css : source.less
  46. "dist/css/AdminLTE.min.css": "build/less/AdminLTE.less",
  47. // Skins minified
  48. "dist/css/skins/skin-blue.min.css": "build/less/skins/skin-blue.less",
  49. "dist/css/skins/skin-black.min.css": "build/less/skins/skin-black.less",
  50. "dist/css/skins/skin-yellow.min.css": "build/less/skins/skin-yellow.less",
  51. "dist/css/skins/skin-green.min.css": "build/less/skins/skin-green.less",
  52. "dist/css/skins/skin-red.min.css": "build/less/skins/skin-red.less",
  53. "dist/css/skins/skin-purple.min.css": "build/less/skins/skin-purple.less",
  54. "dist/css/skins/skin-blue-light.min.css": "build/less/skins/skin-blue-light.less",
  55. "dist/css/skins/skin-black-light.min.css": "build/less/skins/skin-black-light.less",
  56. "dist/css/skins/skin-yellow-light.min.css": "build/less/skins/skin-yellow-light.less",
  57. "dist/css/skins/skin-green-light.min.css": "build/less/skins/skin-green-light.less",
  58. "dist/css/skins/skin-red-light.min.css": "build/less/skins/skin-red-light.less",
  59. "dist/css/skins/skin-purple-light.min.css": "build/less/skins/skin-purple-light.less",
  60. "dist/css/skins/_all-skins.min.css": "build/less/skins/_all-skins.less"
  61. }
  62. }
  63. },
  64. // SASS compiler
  65. sass: {
  66. development: {
  67. options: {
  68. style: 'expanded'
  69. },
  70. files: {
  71. 'dist/tmp/AdminLTE.css': 'build/scss/AdminLTE.scss'
  72. }
  73. },
  74. production: {
  75. options: {
  76. style: 'compressed'
  77. },
  78. files: {
  79. 'dist/tmp/AdminLTE.min.css': 'build/scss/AdminLTE.scss'
  80. }
  81. }
  82. },
  83. // Uglify task info. Compress the js files.
  84. uglify: {
  85. options: {
  86. mangle: true,
  87. preserveComments: 'some'
  88. },
  89. my_target: {
  90. files: {
  91. 'dist/js/app.min.js': ['dist/js/app.js']
  92. }
  93. }
  94. },
  95. // Build the documentation files
  96. includes: {
  97. build: {
  98. src: ['*.html'], // Source files
  99. dest: 'documentation/', // Destination directory
  100. flatten: true,
  101. cwd: 'documentation/build',
  102. options: {
  103. silent: true,
  104. includePath: 'documentation/build/include'
  105. }
  106. }
  107. },
  108. // Optimize images
  109. image: {
  110. dynamic: {
  111. files: [{
  112. expand: true,
  113. cwd: 'build/img/',
  114. src: ['**/*.{png,jpg,gif,svg,jpeg}'],
  115. dest: 'dist/img/'
  116. }]
  117. }
  118. },
  119. // Validate JS code
  120. jshint: {
  121. options: {
  122. jshintrc: '.jshintrc'
  123. },
  124. core: {
  125. src: 'dist/js/app.js'
  126. },
  127. demo: {
  128. src: 'dist/js/demo.js'
  129. },
  130. pages: {
  131. src: 'dist/js/pages/*.js'
  132. }
  133. },
  134. // Validate CSS files
  135. csslint: {
  136. options: {
  137. csslintrc: 'build/less/.csslintrc'
  138. },
  139. dist: [
  140. 'dist/css/AdminLTE.css',
  141. ]
  142. },
  143. // Validate Bootstrap HTML
  144. bootlint: {
  145. options: {
  146. relaxerror: ['W005']
  147. },
  148. files: ['pages/**/*.html', '*.html']
  149. },
  150. // Delete images in build directory
  151. // After compressing the images in the build/img dir, there is no need
  152. // for them
  153. clean: {
  154. build: ["build/img/*"]
  155. }
  156. });
  157. // Load all grunt tasks
  158. // LESS Compiler
  159. grunt.loadNpmTasks('grunt-contrib-less');
  160. // SASS compiler
  161. grunt.loadNpmTasks('grunt-contrib-sass');
  162. // Watch File Changes
  163. grunt.loadNpmTasks('grunt-contrib-watch');
  164. // Compress JS Files
  165. grunt.loadNpmTasks('grunt-contrib-uglify');
  166. // Include Files Within HTML
  167. grunt.loadNpmTasks('grunt-includes');
  168. // Optimize images
  169. grunt.loadNpmTasks('grunt-image');
  170. // Validate JS code
  171. grunt.loadNpmTasks('grunt-contrib-jshint');
  172. // Delete not needed files
  173. grunt.loadNpmTasks('grunt-contrib-clean');
  174. // Lint CSS
  175. grunt.loadNpmTasks('grunt-contrib-csslint');
  176. // Lint Bootstrap
  177. grunt.loadNpmTasks('grunt-bootlint');
  178. // Linting task
  179. grunt.registerTask('lint', ['jshint', 'csslint', 'bootlint']);
  180. // The default task (running "grunt" in console) is "watch"
  181. grunt.registerTask('default', ['watch']);
  182. };