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.

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