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.

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