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.

273 lines
5.9 KiB

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