You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
4.7 KiB

  1. module.exports = function(grunt) {
  2. var
  3. tasks = [
  4. // clean build directory
  5. 'clean:build',
  6. // compiles less
  7. 'less:buildCSS',
  8. // copies assets and js over to build dir
  9. 'copy:toBuild',
  10. // creates minified css of each file
  11. 'cssmin:minifyCSS',
  12. // creates release css
  13. 'cssmin:buildReleaseCSS',
  14. // creates minified js of each file
  15. 'uglify:minifyJS',
  16. // creates release js of all together
  17. 'uglify:buildReleaseJS',
  18. // cleans docs folder
  19. 'clean:docs',
  20. // copies files over to docs
  21. 'copy:toDocs'
  22. ],
  23. config
  24. ;
  25. config = {
  26. package: grunt.file.readJSON('package.json'),
  27. // watches for changes in a source folder
  28. watch: {
  29. scripts: {
  30. files: [
  31. '../src/**/*.less'
  32. ],
  33. tasks : tasks
  34. }
  35. },
  36. clean: {
  37. build : {
  38. cwd: '../build',
  39. src: '*'
  40. },
  41. docs : {
  42. cwd: 'src/files/components/semantic/',
  43. src: '*'
  44. }
  45. },
  46. less: {
  47. options: {
  48. compress : false,
  49. optimization : 2
  50. },
  51. buildCSS: {
  52. options : {
  53. paths : ['../build']
  54. },
  55. expand : true,
  56. cwd : '../src',
  57. src : [
  58. '**/*.less'
  59. ],
  60. dest : '../build/uncompressed',
  61. ext : '.css'
  62. }
  63. },
  64. copy: {
  65. toBuild: {
  66. files: [
  67. {
  68. expand : true,
  69. cwd : '../src/',
  70. src : [
  71. '**/*.js',
  72. 'images/*',
  73. 'fonts/*'
  74. ],
  75. dest : '../build/uncompressed'
  76. },
  77. {
  78. expand : true,
  79. cwd : '../src/',
  80. src : [
  81. '**/*.js',
  82. 'images/*',
  83. 'fonts/*'
  84. ],
  85. dest : '../build/minified'
  86. },
  87. {
  88. expand : true,
  89. cwd : '../src/',
  90. src : [
  91. '**/*.js',
  92. 'images/*',
  93. 'fonts/*'
  94. ],
  95. dest : '../build/packaged'
  96. }
  97. ]
  98. },
  99. toDocs: {
  100. files: [
  101. {
  102. expand : true,
  103. cwd : '../build/uncompressed',
  104. src : [
  105. '**'
  106. ],
  107. dest : 'src/files/components/semantic/'
  108. }
  109. ]
  110. }
  111. },
  112. cssmin: {
  113. minifyCSS: {
  114. expand : true,
  115. cwd : '../build/uncompressed',
  116. src : [
  117. '**/*.css'
  118. ],
  119. dest : '../build/minified',
  120. ext : '.min.css'
  121. },
  122. buildReleaseCSS: {
  123. options : {
  124. banner : '' +
  125. '/*\n' +
  126. '* # <%= package.semantic.name %>\n' +
  127. '* Version: <%= package.semantic.version %>\n' +
  128. '* http://github.com/quirkyinc/semantic\n' +
  129. '*\n' +
  130. '*\n' +
  131. '* Copyright <%= grunt.template.today("yyyy") %> Contributors\n' +
  132. '* Released under the MIT license\n' +
  133. '* http://opensource.org/licenses/MIT\n' +
  134. '*\n' +
  135. '* Released: <%= grunt.template.today("mm/dd/yyyy") %>\n' +
  136. '*/\n'
  137. },
  138. files: {
  139. '../build/packaged/semantic.min.css': [
  140. '../build/uncompressed/**/*.css'
  141. ]
  142. }
  143. }
  144. },
  145. uglify: {
  146. minifyJS: {
  147. expand : true,
  148. cwd : '../build/uncompressed',
  149. src : [
  150. '**/*.js'
  151. ],
  152. dest : '../build/minified',
  153. ext : '.min.js'
  154. },
  155. buildReleaseJS: {
  156. options: {
  157. mangle : true,
  158. compress : true,
  159. banner : '' +
  160. '/*' +
  161. '* # <%= package.semantic.name %>\n' +
  162. '* Version: <%= package.semantic.version %>\n' +
  163. '* http://github.com/quirkyinc/semantic\n' +
  164. '*\n' +
  165. '*\n' +
  166. '* Copyright <%= grunt.template.today("yyyy") %> Contributors\n' +
  167. '* Released under the MIT license\n' +
  168. '* http://opensource.org/licenses/MIT\n' +
  169. '*\n' +
  170. '* Released: <%= grunt.template.today("mm/dd/yyyy") %>\n' +
  171. '*/\n'
  172. },
  173. files: {
  174. '../build/packaged/semantic.min.js': [
  175. '../build/uncompressed/**/*.js'
  176. ]
  177. }
  178. }
  179. }
  180. };
  181. grunt.loadNpmTasks('grunt-contrib-clean');
  182. grunt.loadNpmTasks('grunt-bower-task');
  183. grunt.loadNpmTasks('grunt-css');
  184. grunt.loadNpmTasks('grunt-contrib-watch');
  185. grunt.loadNpmTasks('grunt-contrib-less');
  186. grunt.loadNpmTasks('grunt-contrib-uglify');
  187. grunt.loadNpmTasks('grunt-contrib-cssmin');
  188. grunt.loadNpmTasks('grunt-contrib-copy');
  189. grunt.initConfig(config);
  190. grunt.registerTask('default', [ 'watch' ]);
  191. };