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.

272 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/release/uncompressed/',
  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. 'images/*',
  120. 'fonts/*'
  121. ],
  122. dest : '../build/packaged'
  123. }
  124. ]
  125. },
  126. libraryToDocs: {
  127. files: [
  128. {
  129. expand : true,
  130. cwd : '../build/',
  131. src : [
  132. '**'
  133. ],
  134. dest : 'src/files/release/'
  135. }
  136. ]
  137. },
  138. specToDocs: {
  139. files: [
  140. {
  141. expand : true,
  142. cwd : '../spec',
  143. src : [
  144. '**'
  145. ],
  146. dest : 'src/files/spec/'
  147. }
  148. ]
  149. }
  150. },
  151. cssmin: {
  152. minifyCSS: {
  153. expand : true,
  154. cwd : '../build/uncompressed',
  155. src : [
  156. '**/*.css'
  157. ],
  158. dest : '../build/minified',
  159. ext : '.min.css'
  160. },
  161. addBanner: {
  162. options : {
  163. banner : '' +
  164. '/*\n' +
  165. '* # <%= package.semantic.name %>\n' +
  166. '* Version: <%= package.semantic.version %>\n' +
  167. '* http://github.com/quirkyinc/semantic\n' +
  168. '*\n' +
  169. '*\n' +
  170. '* Copyright <%= grunt.template.today("yyyy") %> Contributors\n' +
  171. '* Released under the MIT license\n' +
  172. '* http://opensource.org/licenses/MIT\n' +
  173. '*\n' +
  174. '* Released: <%= grunt.template.today("mm/dd/yyyy") %>\n' +
  175. '*/\n'
  176. },
  177. files: {
  178. '../build/packaged/css/semantic.min.css': [
  179. '../build/uncompressed/**/*.css'
  180. ]
  181. }
  182. }
  183. },
  184. uglify: {
  185. minifyJS: {
  186. expand : true,
  187. cwd : '../build/uncompressed',
  188. src : [
  189. '**/*.js'
  190. ],
  191. dest : '../build/minified',
  192. ext : '.min.js'
  193. },
  194. buildReleaseJS: {
  195. options: {
  196. mangle : true,
  197. compress : true,
  198. banner : '' +
  199. '/*' +
  200. '* # <%= package.semantic.name %>\n' +
  201. '* Version: <%= package.semantic.version %>\n' +
  202. '* http://github.com/quirkyinc/semantic\n' +
  203. '*\n' +
  204. '*\n' +
  205. '* Copyright <%= grunt.template.today("yyyy") %> Contributors\n' +
  206. '* Released under the MIT license\n' +
  207. '* http://opensource.org/licenses/MIT\n' +
  208. '*\n' +
  209. '* Released: <%= grunt.template.today("mm/dd/yyyy") %>\n' +
  210. '*/\n'
  211. },
  212. files: {
  213. '../build/packaged/javascript/semantic.min.js': [
  214. '../build/uncompressed/**/*.js'
  215. ]
  216. }
  217. }
  218. },
  219. s3: {
  220. options: '<%= server.cdn %>',
  221. deploy: {
  222. options: {
  223. },
  224. upload: [
  225. {
  226. src: '../docs',
  227. dest: 'docs'
  228. }
  229. ]
  230. }
  231. }
  232. };
  233. grunt.loadNpmTasks('grunt-contrib-clean');
  234. grunt.loadNpmTasks('grunt-docco');
  235. grunt.loadNpmTasks('grunt-bower-task');
  236. grunt.loadNpmTasks('grunt-css');
  237. grunt.loadNpmTasks('grunt-contrib-watch');
  238. grunt.loadNpmTasks('grunt-contrib-less');
  239. grunt.loadNpmTasks('grunt-contrib-uglify');
  240. grunt.loadNpmTasks('grunt-contrib-cssmin');
  241. grunt.loadNpmTasks('grunt-contrib-copy');
  242. grunt.initConfig(config);
  243. grunt.registerTask('default', defaultTasks);
  244. grunt.registerTask('build', buildTasks);
  245. };