Gruntfile.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. // AdminLTE Gruntfile
  2. module.exports = function (grunt) { // jshint ignore:line
  3. 'use strict'
  4. grunt.initConfig({
  5. pkg : grunt.file.readJSON('package.json'),
  6. watch : {
  7. less : {
  8. // Compiles less files upon saving
  9. files: ['build/less/*.less'],
  10. tasks: ['less:development', 'less:production', 'notify:less']
  11. },
  12. js : {
  13. // Compile js files upon saving
  14. files: ['build/js/*.js', 'dist/js/app.js'],
  15. tasks: ['js', 'notify:js']
  16. },
  17. skins: {
  18. // Compile any skin less files upon saving
  19. files: ['build/less/skins/*.less'],
  20. tasks: ['less:skins', 'less:minifiedSkins', 'notify:less']
  21. }
  22. },
  23. // Notify end of tasks
  24. notify: {
  25. less: {
  26. options: {
  27. title : 'AdminLTE',
  28. message: 'LESS finished running'
  29. }
  30. },
  31. js : {
  32. options: {
  33. title : 'AdminLTE',
  34. message: 'JS bundler finished running'
  35. }
  36. }
  37. },
  38. // 'less'-task configuration
  39. // This task will compile all less files upon saving to create both AdminLTE.css and AdminLTE.min.css
  40. less : {
  41. // Development not compressed
  42. development : {
  43. files: {
  44. // compilation.css : source.less
  45. 'dist/css/AdminLTE.css' : 'build/less/AdminLTE.less',
  46. // AdminLTE without plugins
  47. 'dist/css/alt/AdminLTE-without-plugins.css' : 'build/less/AdminLTE-without-plugins.less',
  48. // Separate plugins
  49. 'dist/css/alt/AdminLTE-select2.css' : 'build/less/select2.less',
  50. 'dist/css/alt/AdminLTE-fullcalendar.css' : 'build/less/fullcalendar.less',
  51. 'dist/css/alt/AdminLTE-bootstrap-social.css': 'build/less/bootstrap-social.less'
  52. }
  53. },
  54. // Production compressed version
  55. production : {
  56. options: {
  57. compress: true
  58. },
  59. files : {
  60. // compilation.css : source.less
  61. 'dist/css/AdminLTE.min.css' : 'build/less/AdminLTE.less',
  62. // AdminLTE without plugins
  63. 'dist/css/alt/AdminLTE-without-plugins.min.css' : 'build/less/AdminLTE-without-plugins.less',
  64. // Separate plugins
  65. 'dist/css/alt/AdminLTE-select2.min.css' : 'build/less/select2.less',
  66. 'dist/css/alt/AdminLTE-fullcalendar.min.css' : 'build/less/fullcalendar.less',
  67. 'dist/css/alt/AdminLTE-bootstrap-social.min.css': 'build/less/bootstrap-social.less'
  68. }
  69. },
  70. // Non minified skin files
  71. skins : {
  72. files: {
  73. 'dist/css/skins/skin-blue.css' : 'build/less/skins/skin-blue.less',
  74. 'dist/css/skins/skin-black.css' : 'build/less/skins/skin-black.less',
  75. 'dist/css/skins/skin-yellow.css' : 'build/less/skins/skin-yellow.less',
  76. 'dist/css/skins/skin-green.css' : 'build/less/skins/skin-green.less',
  77. 'dist/css/skins/skin-red.css' : 'build/less/skins/skin-red.less',
  78. 'dist/css/skins/skin-purple.css' : 'build/less/skins/skin-purple.less',
  79. 'dist/css/skins/skin-blue-light.css' : 'build/less/skins/skin-blue-light.less',
  80. 'dist/css/skins/skin-black-light.css' : 'build/less/skins/skin-black-light.less',
  81. 'dist/css/skins/skin-yellow-light.css': 'build/less/skins/skin-yellow-light.less',
  82. 'dist/css/skins/skin-green-light.css' : 'build/less/skins/skin-green-light.less',
  83. 'dist/css/skins/skin-red-light.css' : 'build/less/skins/skin-red-light.less',
  84. 'dist/css/skins/skin-purple-light.css': 'build/less/skins/skin-purple-light.less',
  85. 'dist/css/skins/_all-skins.css' : 'build/less/skins/_all-skins.less'
  86. }
  87. },
  88. // Skins minified
  89. minifiedSkins: {
  90. options: {
  91. compress: true
  92. },
  93. files : {
  94. 'dist/css/skins/skin-blue.min.css' : 'build/less/skins/skin-blue.less',
  95. 'dist/css/skins/skin-black.min.css' : 'build/less/skins/skin-black.less',
  96. 'dist/css/skins/skin-yellow.min.css' : 'build/less/skins/skin-yellow.less',
  97. 'dist/css/skins/skin-green.min.css' : 'build/less/skins/skin-green.less',
  98. 'dist/css/skins/skin-red.min.css' : 'build/less/skins/skin-red.less',
  99. 'dist/css/skins/skin-purple.min.css' : 'build/less/skins/skin-purple.less',
  100. 'dist/css/skins/skin-blue-light.min.css' : 'build/less/skins/skin-blue-light.less',
  101. 'dist/css/skins/skin-black-light.min.css' : 'build/less/skins/skin-black-light.less',
  102. 'dist/css/skins/skin-yellow-light.min.css': 'build/less/skins/skin-yellow-light.less',
  103. 'dist/css/skins/skin-green-light.min.css' : 'build/less/skins/skin-green-light.less',
  104. 'dist/css/skins/skin-red-light.min.css' : 'build/less/skins/skin-red-light.less',
  105. 'dist/css/skins/skin-purple-light.min.css': 'build/less/skins/skin-purple-light.less',
  106. 'dist/css/skins/_all-skins.min.css' : 'build/less/skins/_all-skins.less'
  107. }
  108. }
  109. },
  110. // Uglify task info. Compress the js files.
  111. uglify: {
  112. options : {
  113. mangle : true,
  114. preserveComments: 'some'
  115. },
  116. production: {
  117. files: {
  118. 'dist/js/app.min.js' : ['dist/js/app.js'],
  119. 'dist/js/adminlte.min.js': ['dist/js/adminlte.js']
  120. }
  121. }
  122. },
  123. // Concatenate JS Files
  124. concat: {
  125. options: {
  126. separator: '\n\n',
  127. banner : '/*! AdminLTE app.js\n'
  128. + '* ================\n'
  129. + '* Main JS application file for AdminLTE v2. This file\n'
  130. + '* should be included in all pages. It controls some layout\n'
  131. + '* options and implements exclusive AdminLTE plugins.\n'
  132. + '*\n'
  133. + '* @Author Almsaeed Studio\n'
  134. + '* @Support <https://www.almsaeedstudio.com>\n'
  135. + '* @Email <abdullah@almsaeedstudio.com>\n'
  136. + '* @version <%= pkg.version %>\n'
  137. + '* @repository <%= pkg.repository.url %>\n'
  138. + '* @license MIT <http://opensource.org/licenses/MIT>\n'
  139. + '*/\n\n'
  140. + '// Make sure jQuery has been loaded\n'
  141. + 'if (typeof jQuery === \'undefined\') {\n'
  142. + 'throw new Error(\'AdminLTE requires jQuery\')\n'
  143. + '}\n\n'
  144. },
  145. dist : {
  146. src : [
  147. 'build/js/Layout.js',
  148. 'build/js/PushMenu.js',
  149. 'build/js/Tree.js',
  150. 'build/js/ControlSidebar.js',
  151. 'build/js/BoxWidget.js',
  152. 'build/js/TodoList.js',
  153. 'build/js/DirectChat.js'
  154. ],
  155. dest: 'dist/js/adminlte.js'
  156. }
  157. },
  158. // Build the documentation files
  159. includes: {
  160. build: {
  161. src : ['*.html'], // Source files
  162. dest : 'documentation/', // Destination directory
  163. flatten: true,
  164. cwd : 'documentation/build',
  165. options: {
  166. silent : true,
  167. includePath: 'documentation/build/include'
  168. }
  169. }
  170. },
  171. // Optimize images
  172. image: {
  173. dynamic: {
  174. files: [
  175. {
  176. expand: true,
  177. cwd : 'build/img/',
  178. src : ['**/*.{png,jpg,gif,svg,jpeg}'],
  179. dest : 'dist/img/'
  180. }
  181. ]
  182. }
  183. },
  184. // Validate JS code
  185. jshint: {
  186. options: {
  187. jshintrc: 'build/js/.jshintrc'
  188. },
  189. grunt : {
  190. options: {
  191. jshintrc: 'build/grunt/.jshintrc'
  192. },
  193. src : 'Gruntfile.js'
  194. },
  195. core : {
  196. src: 'build/js/*.js'
  197. },
  198. demo : {
  199. src: 'dist/js/demo.js'
  200. },
  201. pages : {
  202. src: 'dist/js/pages/*.js'
  203. }
  204. },
  205. jscs: {
  206. options: {
  207. config: 'build/js/.jscsrc'
  208. },
  209. core : {
  210. src: '<%= jshint.core.src %>'
  211. },
  212. pages : {
  213. src: '<%= jshint.pages.src %>'
  214. }
  215. },
  216. // Validate CSS files
  217. csslint: {
  218. options: {
  219. csslintrc: 'build/less/.csslintrc'
  220. },
  221. dist : [
  222. 'dist/css/AdminLTE.css'
  223. ]
  224. },
  225. // Validate Bootstrap HTML
  226. bootlint: {
  227. options: {
  228. relaxerror: ['W005']
  229. },
  230. files : ['pages/**/*.html', '*.html']
  231. },
  232. // Delete images in build directory
  233. // After compressing the images in the build/img dir, there is no need
  234. // for them
  235. clean: {
  236. build: ['build/img/*']
  237. }
  238. })
  239. // Load all grunt tasks
  240. // LESS Compiler
  241. grunt.loadNpmTasks('grunt-contrib-less')
  242. // Watch File Changes
  243. grunt.loadNpmTasks('grunt-contrib-watch')
  244. // Compress JS Files
  245. grunt.loadNpmTasks('grunt-contrib-uglify')
  246. // Include Files Within HTML
  247. grunt.loadNpmTasks('grunt-includes')
  248. // Optimize images
  249. grunt.loadNpmTasks('grunt-image')
  250. // Validate JS code
  251. grunt.loadNpmTasks('grunt-contrib-jshint')
  252. grunt.loadNpmTasks('grunt-jscs')
  253. // Delete not needed files
  254. grunt.loadNpmTasks('grunt-contrib-clean')
  255. // Lint CSS
  256. grunt.loadNpmTasks('grunt-contrib-csslint')
  257. // Lint Bootstrap
  258. grunt.loadNpmTasks('grunt-bootlint')
  259. // Concatenate JS files
  260. grunt.loadNpmTasks('grunt-contrib-concat')
  261. // Notify
  262. grunt.loadNpmTasks('grunt-notify')
  263. // Linting task
  264. grunt.registerTask('lint', ['jshint', 'csslint', 'bootlint'])
  265. // JS task
  266. grunt.registerTask('js', ['concat', 'uglify'])
  267. // The default task (running 'grunt' in console) is 'watch'
  268. grunt.registerTask('default', ['watch'])
  269. }