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.

231 lines
5.0 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. '../src/**/*.js'
  33. ],
  34. tasks : tasks
  35. }
  36. },
  37. clean: {
  38. build : {
  39. cwd: '../build',
  40. src: '*'
  41. },
  42. docs : {
  43. cwd: 'src/files/components/semantic/',
  44. src: '*'
  45. }
  46. },
  47. docco: {
  48. generate: {
  49. expand : true,
  50. cwd : '../spec',
  51. src : [
  52. '**/*.commented.js'
  53. ],
  54. options: {
  55. output: 'src/files/generated/'
  56. }
  57. }
  58. },
  59. less: {
  60. options: {
  61. compress : false,
  62. optimization : 2
  63. },
  64. buildCSS: {
  65. options : {
  66. paths : ['../build']
  67. },
  68. expand : true,
  69. cwd : '../src',
  70. src : [
  71. '**/*.less'
  72. ],
  73. dest : '../build/uncompressed',
  74. ext : '.css'
  75. }
  76. },
  77. copy: {
  78. toBuild: {
  79. files: [
  80. {
  81. expand : true,
  82. cwd : '../src/',
  83. src : [
  84. '**/*.js',
  85. 'images/*',
  86. 'fonts/*'
  87. ],
  88. dest : '../build/uncompressed'
  89. },
  90. {
  91. expand : true,
  92. cwd : '../src/',
  93. src : [
  94. '**/*.js',
  95. 'images/*',
  96. 'fonts/*'
  97. ],
  98. dest : '../build/minified'
  99. },
  100. {
  101. expand : true,
  102. cwd : '../src/',
  103. src : [
  104. '**/*.js',
  105. 'images/*',
  106. 'fonts/*'
  107. ],
  108. dest : '../build/packaged'
  109. }
  110. ]
  111. },
  112. toDocs: {
  113. files: [
  114. {
  115. expand : true,
  116. cwd : '../build/uncompressed',
  117. src : [
  118. '**'
  119. ],
  120. dest : 'src/files/components/semantic/'
  121. }
  122. ]
  123. }
  124. },
  125. cssmin: {
  126. minifyCSS: {
  127. expand : true,
  128. cwd : '../build/uncompressed',
  129. src : [
  130. '**/*.css'
  131. ],
  132. dest : '../build/minified',
  133. ext : '.min.css'
  134. },
  135. buildReleaseCSS: {
  136. options : {
  137. banner : '' +
  138. '/*\n' +
  139. '* # <%= package.semantic.name %>\n' +
  140. '* Version: <%= package.semantic.version %>\n' +
  141. '* http://github.com/quirkyinc/semantic\n' +
  142. '*\n' +
  143. '*\n' +
  144. '* Copyright <%= grunt.template.today("yyyy") %> Contributors\n' +
  145. '* Released under the MIT license\n' +
  146. '* http://opensource.org/licenses/MIT\n' +
  147. '*\n' +
  148. '* Released: <%= grunt.template.today("mm/dd/yyyy") %>\n' +
  149. '*/\n'
  150. },
  151. files: {
  152. '../build/packaged/semantic.min.css': [
  153. '../build/uncompressed/**/*.css'
  154. ]
  155. }
  156. }
  157. },
  158. uglify: {
  159. minifyJS: {
  160. expand : true,
  161. cwd : '../build/uncompressed',
  162. src : [
  163. '**/*.js'
  164. ],
  165. dest : '../build/minified',
  166. ext : '.min.js'
  167. },
  168. buildReleaseJS: {
  169. options: {
  170. mangle : true,
  171. compress : true,
  172. banner : '' +
  173. '/*' +
  174. '* # <%= package.semantic.name %>\n' +
  175. '* Version: <%= package.semantic.version %>\n' +
  176. '* http://github.com/quirkyinc/semantic\n' +
  177. '*\n' +
  178. '*\n' +
  179. '* Copyright <%= grunt.template.today("yyyy") %> Contributors\n' +
  180. '* Released under the MIT license\n' +
  181. '* http://opensource.org/licenses/MIT\n' +
  182. '*\n' +
  183. '* Released: <%= grunt.template.today("mm/dd/yyyy") %>\n' +
  184. '*/\n'
  185. },
  186. files: {
  187. '../build/packaged/semantic.min.js': [
  188. '../build/uncompressed/**/*.js'
  189. ]
  190. }
  191. }
  192. }
  193. };
  194. grunt.loadNpmTasks('grunt-contrib-clean');
  195. grunt.loadNpmTasks('grunt-docco');
  196. grunt.loadNpmTasks('grunt-bower-task');
  197. grunt.loadNpmTasks('grunt-css');
  198. grunt.loadNpmTasks('grunt-contrib-watch');
  199. grunt.loadNpmTasks('grunt-contrib-less');
  200. grunt.loadNpmTasks('grunt-contrib-uglify');
  201. grunt.loadNpmTasks('grunt-contrib-cssmin');
  202. grunt.loadNpmTasks('grunt-contrib-copy');
  203. grunt.initConfig(config);
  204. grunt.registerTask('default', [ 'watch' ]);
  205. };