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.
 
 
 

279 lines
7.4 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,svg}',
  127. '<%= yeoman.dist %>/fonts/{,*/}*.*'
  128. ]
  129. }
  130. }
  131. },
  132. useminPrepare: {
  133. html: '<%= yeoman.app %>/*.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. cssmin: {
  156. dist: {
  157. files: {
  158. '<%= yeoman.dist %>/styles/main.css': [
  159. '.tmp/styles/{,*/}*.css',
  160. '<%= yeoman.app %>/styles/{,*/}*.css'
  161. ]
  162. }
  163. }
  164. },
  165. htmlmin: {
  166. dist: {
  167. options: {
  168. /*removeCommentsFromCDATA: true,
  169. // https://github.com/yeoman/grunt-usemin/issues/44
  170. //collapseWhitespace: true,
  171. collapseBooleanAttributes: true,
  172. removeAttributeQuotes: true,
  173. removeRedundantAttributes: true,
  174. useShortDoctype: true,
  175. removeEmptyAttributes: true,
  176. removeOptionalTags: true*/
  177. },
  178. files: [{
  179. expand: true,
  180. cwd: '<%= yeoman.app %>',
  181. src: '*.html',
  182. dest: '<%= yeoman.dist %>'
  183. }]
  184. }
  185. },
  186. copy: {
  187. dist: {
  188. files: [{
  189. expand: true,
  190. dot: true,
  191. cwd: '<%= yeoman.app %>',
  192. dest: '<%= yeoman.dist %>',
  193. src: [
  194. '*.{ico,png,txt}',
  195. 'fonts/{,*/}*.*',
  196. '.htaccess',
  197. 'index.txt',
  198. '404.txt',
  199. 'images/{,*/}*.{webp,gif,svg}'
  200. ]
  201. }]
  202. },
  203. server: {
  204. files: [{
  205. expand: true,
  206. dot: true,
  207. cwd: '<%= yeoman.app %>/bower_components/font-awesome/fonts/',
  208. dest: '<%= yeoman.app %>/fonts/font-awesome',
  209. src: ['*']
  210. }, {
  211. expand: true,
  212. dot: true,
  213. cwd: '<%= yeoman.app %>/bower_components/bootstrap/dist/fonts/',
  214. dest: '<%= yeoman.app %>/fonts/glyphicons',
  215. src: ['*']
  216. }]
  217. }
  218. },
  219. concurrent: {
  220. dist: [
  221. 'less',
  222. 'imagemin',
  223. 'htmlmin'
  224. ]
  225. }
  226. });
  227. grunt.registerTask('serve', function (target) {
  228. if (target === 'dist') {
  229. return grunt.task.run(['build', 'connect:dist:keepalive']);
  230. }
  231. grunt.task.run([
  232. 'clean:server',
  233. 'less',
  234. 'copy:server',
  235. 'connect:livereload',
  236. 'watch'
  237. ]);
  238. });
  239. grunt.registerTask('server', function () {
  240. grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
  241. grunt.task.run(['serve']);
  242. });
  243. grunt.registerTask('test', [
  244. 'clean:server',
  245. 'less',
  246. 'copy:server',
  247. 'connect:test',
  248. ]);
  249. grunt.registerTask('build', [
  250. 'clean:dist',
  251. 'copy:server',
  252. 'useminPrepare',
  253. 'concurrent',
  254. 'cssmin',
  255. 'concat',
  256. 'uglify',
  257. 'copy',
  258. 'usemin'
  259. ]);
  260. grunt.registerTask('default', [
  261. 'jshint',
  262. 'test',
  263. 'build'
  264. ]);
  265. };