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.
 
 
 

288 lines
7.7 KiB

  1. 'use strict';
  2. // # Globbing
  3. // for performance reasons we're only matching one level down:
  4. // 'test/spec/{,*/}*.js'
  5. // use this if you want to match all subfolders:
  6. // 'test/spec/**/*.js'
  7. module.exports = function (grunt) {
  8. // load all grunt tasks
  9. require('load-grunt-tasks')(grunt);
  10. // show elapsed time at the end
  11. require('time-grunt')(grunt);
  12. // configurable paths
  13. var yeomanConfig = {
  14. app: require('./bower.json').appPath || 'transfersh-web',
  15. dist: 'transfersh-server/static/'
  16. };
  17. grunt.initConfig({
  18. yeoman: yeomanConfig,
  19. watch: {
  20. less: {
  21. files: ['<%= yeoman.app %>/styles/{,*/}*.less'],
  22. tasks: ['less']
  23. },
  24. gruntfile: {
  25. files: ['Gruntfile.js']
  26. },
  27. livereload: {
  28. options: {
  29. livereload: '<%= connect.options.livereload %>'
  30. },
  31. files: [
  32. '<%= yeoman.app %>/*.html',
  33. '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
  34. '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
  35. '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
  36. ]
  37. }
  38. },
  39. connect: {
  40. options: {
  41. port: 9000,
  42. // change this to '0.0.0.0' to access the server from outside
  43. hostname: 'localhost',
  44. livereload: 35729
  45. },
  46. livereload: {
  47. options: {
  48. open: true,
  49. base: [
  50. '.tmp',
  51. '<%= yeoman.app %>'
  52. ]
  53. }
  54. },
  55. test: {
  56. options: {
  57. port: 9001,
  58. base: [
  59. '.tmp',
  60. 'test',
  61. '<%= yeoman.app %>'
  62. ]
  63. }
  64. },
  65. dist: {
  66. options: {
  67. base: '<%= yeoman.dist %>'
  68. }
  69. }
  70. },
  71. clean: {
  72. dist: {
  73. files: [{
  74. dot: true,
  75. src: [
  76. '.tmp',
  77. '<%= yeoman.dist %>/*',
  78. '!<%= yeoman.dist %>/.git*'
  79. ]
  80. }]
  81. },
  82. server: '.tmp'
  83. },
  84. jshint: {
  85. options: {
  86. jshintrc: '.jshintrc',
  87. reporter: require('jshint-stylish')
  88. },
  89. all: [
  90. 'Gruntfile.js',
  91. '<%= yeoman.app %>/scripts/{,*/}*.js',
  92. '!<%= yeoman.app %>/scripts/vendor/*',
  93. 'test/spec/{,*/}*.js'
  94. ]
  95. },
  96. less: {
  97. dist: {
  98. files: {
  99. '<%= yeoman.app %>/styles/main.css': ['<%= yeoman.app %>/styles/main.less']
  100. },
  101. options: {
  102. sourceMap: true,
  103. sourceMapFilename: '<%= yeoman.app %>/styles/main.css.map',
  104. sourceMapBasepath: '<%= yeoman.app %>/',
  105. sourceMapRootpath: '/'
  106. }
  107. }
  108. },
  109. // not used since Uglify task does concat,
  110. // but still available if needed
  111. /*concat: {
  112. dist: {}
  113. },*/
  114. // not enabled since usemin task does concat and uglify
  115. // check index.html to edit your build targets
  116. // enable this task if you prefer defining your build targets here
  117. /*uglify: {
  118. dist: {}
  119. },*/
  120. rev: {
  121. dist: {
  122. files: {
  123. src: [
  124. '<%= yeoman.dist %>/scripts/{,*/}*.js',
  125. '<%= yeoman.dist %>/styles/{,*/}*.css',
  126. '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
  127. '<%= yeoman.dist %>/fonts/{,*/}*.*'
  128. ]
  129. }
  130. }
  131. },
  132. useminPrepare: {
  133. html: '<%= yeoman.app %>/index.html',
  134. options: {
  135. dest: '<%= yeoman.dist %>'
  136. }
  137. },
  138. usemin: {
  139. html: ['<%= yeoman.dist %>/{,*/}*.html'],
  140. css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
  141. options: {
  142. dirs: ['<%= yeoman.dist %>']
  143. }
  144. },
  145. imagemin: {
  146. dist: {
  147. files: [{
  148. expand: true,
  149. cwd: '<%= yeoman.app %>/images',
  150. src: '{,*/}*.{png,jpg,jpeg}',
  151. dest: '<%= yeoman.dist %>/images'
  152. }]
  153. }
  154. },
  155. svgmin: {
  156. dist: {
  157. files: [{
  158. expand: true,
  159. cwd: '<%= yeoman.app %>/images',
  160. src: '{,*/}*.svg',
  161. dest: '<%= yeoman.dist %>/images'
  162. }]
  163. }
  164. },
  165. cssmin: {
  166. dist: {
  167. files: {
  168. '<%= yeoman.dist %>/styles/main.css': [
  169. '.tmp/styles/{,*/}*.css',
  170. '<%= yeoman.app %>/styles/{,*/}*.css'
  171. ]
  172. }
  173. }
  174. },
  175. htmlmin: {
  176. dist: {
  177. options: {
  178. /*removeCommentsFromCDATA: true,
  179. // https://github.com/yeoman/grunt-usemin/issues/44
  180. //collapseWhitespace: true,
  181. collapseBooleanAttributes: true,
  182. removeAttributeQuotes: true,
  183. removeRedundantAttributes: true,
  184. useShortDoctype: true,
  185. removeEmptyAttributes: true,
  186. removeOptionalTags: true*/
  187. },
  188. files: [{
  189. expand: true,
  190. cwd: '<%= yeoman.app %>',
  191. src: '*.html',
  192. dest: '<%= yeoman.dist %>'
  193. }]
  194. }
  195. },
  196. copy: {
  197. dist: {
  198. files: [{
  199. expand: true,
  200. dot: true,
  201. cwd: '<%= yeoman.app %>',
  202. dest: '<%= yeoman.dist %>',
  203. src: [
  204. '*.{ico,png,txt}',
  205. 'fonts/{,*/}*.*',
  206. '.htaccess',
  207. 'index.txt',
  208. 'images/{,*/}*.{webp,gif}'
  209. ]
  210. }]
  211. },
  212. server: {
  213. files: [{
  214. expand: true,
  215. dot: true,
  216. cwd: '<%= yeoman.app %>/bower_components/font-awesome/fonts/',
  217. dest: '<%= yeoman.app %>/fonts/font-awesome',
  218. src: ['*']
  219. }, {
  220. expand: true,
  221. dot: true,
  222. cwd: '<%= yeoman.app %>/bower_components/bootstrap/dist/fonts/',
  223. dest: '<%= yeoman.app %>/fonts/glyphicons',
  224. src: ['*']
  225. }]
  226. }
  227. },
  228. concurrent: {
  229. dist: [
  230. 'less',
  231. 'imagemin',
  232. 'svgmin',
  233. 'htmlmin'
  234. ]
  235. }
  236. });
  237. grunt.registerTask('serve', function (target) {
  238. if (target === 'dist') {
  239. return grunt.task.run(['build', 'connect:dist:keepalive']);
  240. }
  241. grunt.task.run([
  242. 'clean:server',
  243. 'less',
  244. 'copy:server',
  245. 'connect:livereload',
  246. 'watch'
  247. ]);
  248. });
  249. grunt.registerTask('server', function () {
  250. grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
  251. grunt.task.run(['serve']);
  252. });
  253. grunt.registerTask('test', [
  254. 'clean:server',
  255. 'less',
  256. 'copy:server',
  257. 'connect:test',
  258. ]);
  259. grunt.registerTask('build', [
  260. 'clean:dist',
  261. 'copy:server',
  262. 'useminPrepare',
  263. 'concurrent',
  264. 'cssmin',
  265. 'concat',
  266. 'uglify',
  267. 'copy',
  268. 'usemin'
  269. ]);
  270. grunt.registerTask('default', [
  271. 'jshint',
  272. 'test',
  273. 'build'
  274. ]);
  275. };