Gruntfile.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. // Generated on 2013-10-07 using generator-webapp 0.4.3
  2. 'use strict';
  3. // # Globbing
  4. // for performance reasons we're only matching one level down:
  5. // 'test/spec/{,*/}*.js'
  6. // use this if you want to recursively match all subfolders:
  7. // 'test/spec/**/*.js'
  8. module.exports = function (grunt) {
  9. // show elapsed time at the end
  10. require('time-grunt')(grunt);
  11. // load all grunt tasks
  12. require('load-grunt-tasks')(grunt);
  13. grunt.initConfig({
  14. // configurable paths
  15. uglify: {
  16. options: {
  17. mangle: false
  18. },
  19. },
  20. yeoman: {
  21. app: 'app',
  22. dist: 'dist'
  23. },
  24. watch: {
  25. compass: {
  26. files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
  27. tasks: ['compass:server', 'autoprefixer']
  28. },
  29. styles: {
  30. files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
  31. tasks: ['copy:styles', 'autoprefixer']
  32. },
  33. livereload: {
  34. options: {
  35. livereload: '<%= connect.options.livereload %>'
  36. },
  37. files: [
  38. '<%= yeoman.app %>/*.html',
  39. '.tmp/styles/{,*/}*.css',
  40. '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
  41. '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
  42. ]
  43. }
  44. },
  45. connect: {
  46. options: {
  47. port: 9000,
  48. livereload: 35729,
  49. // change this to '0.0.0.0' to access the server from outside
  50. hostname: 'localhost'
  51. },
  52. livereload: {
  53. options: {
  54. open: true,
  55. base: [
  56. '.tmp',
  57. '<%= yeoman.app %>'
  58. ]
  59. }
  60. },
  61. test: {
  62. options: {
  63. base: [
  64. '.tmp',
  65. 'test',
  66. '<%= yeoman.app %>'
  67. ]
  68. }
  69. },
  70. dist: {
  71. options: {
  72. open: true,
  73. base: '<%= yeoman.dist %>'
  74. }
  75. }
  76. },
  77. clean: {
  78. dist: {
  79. files: [{
  80. dot: true,
  81. src: [
  82. '.tmp',
  83. '<%= yeoman.dist %>/*',
  84. '!<%= yeoman.dist %>/.git*'
  85. ]
  86. }]
  87. },
  88. server: '.tmp'
  89. },
  90. jshint: {
  91. options: {
  92. jshintrc: '.jshintrc'
  93. },
  94. all: [
  95. '<%= yeoman.app %>/scripts/{,*/}*.js',
  96. '!<%= yeoman.app %>/scripts/vendor/*',
  97. ]
  98. },
  99. mocha: {
  100. all: {
  101. options: {
  102. run: true,
  103. urls: ['http://<%= connect.test.options.hostname %>:<%= connect.test.options.port %>/index.html']
  104. }
  105. }
  106. },
  107. compass: {
  108. options: {
  109. sassDir: '<%= yeoman.app %>/styles',
  110. cssDir: '.tmp/styles',
  111. generatedImagesDir: '.tmp/images/generated',
  112. imagesDir: '<%= yeoman.app %>/images',
  113. javascriptsDir: '<%= yeoman.app %>/scripts',
  114. fontsDir: '<%= yeoman.app %>/styles/fonts',
  115. importPath: '<%= yeoman.app %>/bower_components',
  116. httpImagesPath: '/images',
  117. httpGeneratedImagesPath: '/images/generated',
  118. httpFontsPath: '/styles/fonts',
  119. relativeAssets: false,
  120. assetCacheBuster: false
  121. },
  122. dist: {
  123. options: {
  124. generatedImagesDir: '<%= yeoman.dist %>/images/generated'
  125. }
  126. },
  127. server: {
  128. options: {
  129. debugInfo: true
  130. }
  131. }
  132. },
  133. autoprefixer: {
  134. options: {
  135. browsers: ['last 1 version']
  136. },
  137. dist: {
  138. files: [{
  139. expand: true,
  140. cwd: '.tmp/styles/',
  141. src: '{,*/}*.css',
  142. dest: '.tmp/styles/'
  143. }]
  144. }
  145. },
  146. // not used since Uglify task does concat,
  147. // but still available if needed
  148. /*concat: {
  149. dist: {}
  150. },*/
  151. requirejs: {
  152. dist: {
  153. // Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
  154. options: {
  155. // `name` and `out` is set by grunt-usemin
  156. baseUrl: '<%= yeoman.app %>/scripts',
  157. optimize: 'none',
  158. // TODO: Figure out how to make sourcemaps work with grunt-usemin
  159. // https://github.com/yeoman/grunt-usemin/issues/30
  160. //generateSourceMaps: true,
  161. // required to support SourceMaps
  162. // http://requirejs.org/docs/errors.html#sourcemapcomments
  163. preserveLicenseComments: false,
  164. useStrict: true,
  165. wrap: true
  166. //uglify2: {} // https://github.com/mishoo/UglifyJS2
  167. }
  168. }
  169. },
  170. useminPrepare: {
  171. options: {
  172. dest: '<%= yeoman.dist %>'
  173. },
  174. html: ['<%= yeoman.app %>/index.html']
  175. },
  176. usemin: {
  177. options: {
  178. dirs: ['<%= yeoman.dist %>']
  179. },
  180. html: ['<%= yeoman.dist %>/{,*/}*.html'],
  181. css: ['<%= yeoman.dist %>/styles/{,*/}*.css']
  182. },
  183. imagemin: {
  184. dist: {
  185. files: [{
  186. expand: true,
  187. cwd: '<%= yeoman.app %>/images',
  188. src: '{,*/}*.{png,jpg,jpeg}',
  189. dest: '<%= yeoman.dist %>/images'
  190. }]
  191. }
  192. },
  193. svgmin: {
  194. dist: {
  195. files: [{
  196. expand: true,
  197. cwd: '<%= yeoman.app %>/images',
  198. src: '{,*/}*.svg',
  199. dest: '<%= yeoman.dist %>/images'
  200. }]
  201. }
  202. },
  203. cssmin: {
  204. // This task is pre-configured if you do not wish to use Usemin
  205. // blocks for your CSS. By default, the Usemin block from your
  206. // `index.html` will take care of minification, e.g.
  207. //
  208. // <!-- build:css({.tmp,app}) styles/main.css -->
  209. //
  210. // dist: {
  211. // files: {
  212. // '<%= yeoman.dist %>/styles/main.css': [
  213. // '.tmp/styles/{,*/}*.css',
  214. // '<%= yeoman.app %>/styles/{,*/}*.css'
  215. // ]
  216. // }
  217. // }
  218. },
  219. htmlmin: {
  220. dist: {
  221. options: {
  222. /*removeCommentsFromCDATA: true,
  223. // https://github.com/yeoman/grunt-usemin/issues/44
  224. //collapseWhitespace: true,
  225. collapseBooleanAttributes: true,
  226. removeAttributeQuotes: true,
  227. removeRedundantAttributes: true,
  228. useShortDoctype: true,
  229. removeEmptyAttributes: true,
  230. removeOptionalTags: true*/
  231. },
  232. files: [{
  233. expand: true,
  234. cwd: '<%= yeoman.app %>',
  235. src: '*.html',
  236. dest: '<%= yeoman.dist %>'
  237. }]
  238. }
  239. },
  240. ngmin: {
  241. dist: {
  242. src: '.tmp/concat/scripts/app.js',
  243. dest: '.tmp/concat/scripts/app.js'
  244. }
  245. },
  246. // Put files not handled in other tasks here
  247. copy: {
  248. dist: {
  249. files: [{
  250. expand: true,
  251. dot: true,
  252. cwd: '<%= yeoman.app %>',
  253. dest: '<%= yeoman.dist %>',
  254. src: [
  255. '*.{ico,png,txt}',
  256. '.htaccess',
  257. 'images/{,*/}*.{webp,gif,svg}',
  258. 'styles/fonts/{,*/}*.*',
  259. 'views/*.*',
  260. //'index.html',
  261. 'bower_components/sass-bootstrap/fonts/*.*'
  262. ]
  263. }]
  264. },
  265. styles: {
  266. expand: true,
  267. dot: true,
  268. cwd: '<%= yeoman.app %>/styles',
  269. dest: '.tmp/styles/',
  270. src: '{,*/}*.css'
  271. }
  272. },
  273. modernizr: {
  274. devFile: '<%= yeoman.app %>/bower_components/modernizr/modernizr.js',
  275. outputFile: '<%= yeoman.dist %>/bower_components/modernizr/modernizr.js',
  276. files: [
  277. '<%= yeoman.dist %>/scripts/{,*/}*.js',
  278. '<%= yeoman.dist %>/styles/{,*/}*.css',
  279. '!<%= yeoman.dist %>/scripts/vendor/*'
  280. ],
  281. uglify: true
  282. },
  283. concurrent: {
  284. server: [
  285. 'compass',
  286. 'copy:styles'
  287. ],
  288. test: [
  289. 'copy:styles'
  290. ],
  291. dist: [
  292. //'compass',
  293. 'copy:styles',
  294. 'imagemin',
  295. 'svgmin',
  296. 'htmlmin'
  297. ]
  298. },
  299. bower: {
  300. options: {
  301. exclude: ['modernizr']
  302. },
  303. all: {
  304. rjsConfig: '<%= yeoman.app %>/scripts/main.js'
  305. }
  306. }
  307. });
  308. grunt.registerTask('server', function (target) {
  309. if (target === 'dist') {
  310. return grunt.task.run(['build', 'connect:dist:keepalive']);
  311. }
  312. grunt.task.run([
  313. 'clean:server',
  314. 'concurrent:server',
  315. 'autoprefixer',
  316. 'connect:livereload',
  317. 'watch'
  318. ]);
  319. });
  320. grunt.registerTask('test', [
  321. 'clean:server',
  322. 'concurrent:test',
  323. 'autoprefixer',
  324. 'connect:test',
  325. 'mocha'
  326. ]);
  327. grunt.registerTask('build', [
  328. 'clean:dist',
  329. 'jshint',
  330. 'useminPrepare',
  331. 'concurrent:dist',
  332. 'autoprefixer',
  333. 'concat',
  334. 'cssmin',
  335. 'ngmin',
  336. 'usemin',
  337. 'uglify',
  338. 'copy:dist'
  339. ]);
  340. grunt.registerTask('default', [
  341. 'jshint',
  342. 'test',
  343. 'build'
  344. ]);
  345. };