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.

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