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.

310 lines
6.6 KiB

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