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.

246 lines
5.3 KiB

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