WIP Domain listing app with automatic status checking. Buitl with AngularJS.

Gruntfile.js 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. // Generated on 2015-05-16 using generator-angular 0.11.1
  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. // Load grunt tasks automatically
  10. require('load-grunt-tasks')(grunt);
  11. // Time how long tasks take. Can help when optimizing build times
  12. require('time-grunt')(grunt);
  13. // Configurable paths for the application
  14. var appConfig = {
  15. app: require('./bower.json').appPath || 'app',
  16. dist: 'dist'
  17. };
  18. // Define the configuration for all the tasks
  19. grunt.initConfig({
  20. // Project settings
  21. yeoman: appConfig,
  22. // Watches files for changes and runs tasks based on the changed files
  23. watch: {
  24. bower: {
  25. files: ['bower.json'],
  26. tasks: ['wiredep']
  27. },
  28. js: {
  29. files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
  30. tasks: ['newer:jshint:all'],
  31. options: {
  32. livereload: '<%= connect.options.livereload %>'
  33. }
  34. },
  35. jsTest: {
  36. files: ['test/spec/{,*/}*.js'],
  37. tasks: ['newer:jshint:test', 'karma']
  38. },
  39. styles: {
  40. files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
  41. tasks: ['newer:copy:styles', 'autoprefixer']
  42. },
  43. gruntfile: {
  44. files: ['Gruntfile.js']
  45. },
  46. livereload: {
  47. options: {
  48. livereload: '<%= connect.options.livereload %>'
  49. },
  50. files: [
  51. '<%= yeoman.app %>/{,*/}*.html',
  52. '.tmp/styles/{,*/}*.css',
  53. '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
  54. ]
  55. }
  56. },
  57. // The actual grunt server settings
  58. connect: {
  59. options: {
  60. port: 9000,
  61. // Change this to '0.0.0.0' to access the server from outside.
  62. hostname: 'localhost',
  63. livereload: 35729
  64. },
  65. livereload: {
  66. options: {
  67. open: true,
  68. middleware: function (connect) {
  69. return [
  70. connect.static('.tmp'),
  71. connect().use(
  72. '/bower_components',
  73. connect.static('./bower_components')
  74. ),
  75. connect().use(
  76. '/app/styles',
  77. connect.static('./app/styles')
  78. ),
  79. connect.static(appConfig.app)
  80. ];
  81. }
  82. }
  83. },
  84. test: {
  85. options: {
  86. port: 9001,
  87. middleware: function (connect) {
  88. return [
  89. connect.static('.tmp'),
  90. connect.static('test'),
  91. connect().use(
  92. '/bower_components',
  93. connect.static('./bower_components')
  94. ),
  95. connect.static(appConfig.app)
  96. ];
  97. }
  98. }
  99. },
  100. dist: {
  101. options: {
  102. open: true,
  103. base: '<%= yeoman.dist %>'
  104. }
  105. }
  106. },
  107. // Make sure code styles are up to par and there are no obvious mistakes
  108. jshint: {
  109. options: {
  110. jshintrc: '.jshintrc',
  111. reporter: require('jshint-stylish')
  112. },
  113. all: {
  114. src: [
  115. 'Gruntfile.js',
  116. '<%= yeoman.app %>/scripts/{,*/}*.js'
  117. ]
  118. },
  119. test: {
  120. options: {
  121. jshintrc: 'test/.jshintrc'
  122. },
  123. src: ['test/spec/{,*/}*.js']
  124. }
  125. },
  126. // Empties folders to start fresh
  127. clean: {
  128. dist: {
  129. files: [{
  130. dot: true,
  131. src: [
  132. '.tmp',
  133. '<%= yeoman.dist %>/{,*/}*',
  134. '!<%= yeoman.dist %>/.git{,*/}*'
  135. ]
  136. }]
  137. },
  138. server: '.tmp'
  139. },
  140. // Add vendor prefixed styles
  141. autoprefixer: {
  142. options: {
  143. browsers: ['last 1 version']
  144. },
  145. server: {
  146. options: {
  147. map: true,
  148. },
  149. files: [{
  150. expand: true,
  151. cwd: '.tmp/styles/',
  152. src: '{,*/}*.css',
  153. dest: '.tmp/styles/'
  154. }]
  155. },
  156. dist: {
  157. files: [{
  158. expand: true,
  159. cwd: '.tmp/styles/',
  160. src: '{,*/}*.css',
  161. dest: '.tmp/styles/'
  162. }]
  163. }
  164. },
  165. // Automatically inject Bower components into the app
  166. wiredep: {
  167. app: {
  168. src: ['<%= yeoman.app %>/index.html'],
  169. ignorePath: /\.\.\//
  170. },
  171. test: {
  172. devDependencies: true,
  173. src: '<%= karma.unit.configFile %>',
  174. ignorePath: /\.\.\//,
  175. fileTypes:{
  176. js: {
  177. block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi,
  178. detect: {
  179. js: /'(.*\.js)'/gi
  180. },
  181. replace: {
  182. js: '\'{{filePath}}\','
  183. }
  184. }
  185. }
  186. }
  187. },
  188. // Renames files for browser caching purposes
  189. filerev: {
  190. dist: {
  191. src: [
  192. '<%= yeoman.dist %>/scripts/{,*/}*.js',
  193. '<%= yeoman.dist %>/styles/{,*/}*.css',
  194. '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
  195. '<%= yeoman.dist %>/styles/fonts/*'
  196. ]
  197. }
  198. },
  199. // Reads HTML for usemin blocks to enable smart builds that automatically
  200. // concat, minify and revision files. Creates configurations in memory so
  201. // additional tasks can operate on them
  202. useminPrepare: {
  203. html: '<%= yeoman.app %>/index.html',
  204. options: {
  205. dest: '<%= yeoman.dist %>',
  206. flow: {
  207. html: {
  208. steps: {
  209. js: ['concat', 'uglifyjs'],
  210. css: ['cssmin']
  211. },
  212. post: {}
  213. }
  214. }
  215. }
  216. },
  217. // Performs rewrites based on filerev and the useminPrepare configuration
  218. usemin: {
  219. html: ['<%= yeoman.dist %>/{,*/}*.html'],
  220. css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
  221. options: {
  222. assetsDirs: [
  223. '<%= yeoman.dist %>',
  224. '<%= yeoman.dist %>/images',
  225. '<%= yeoman.dist %>/styles'
  226. ]
  227. }
  228. },
  229. // The following *-min tasks will produce minified files in the dist folder
  230. // By default, your `index.html`'s <!-- Usemin block --> will take care of
  231. // minification. These next options are pre-configured if you do not wish
  232. // to use the Usemin blocks.
  233. // cssmin: {
  234. // dist: {
  235. // files: {
  236. // '<%= yeoman.dist %>/styles/main.css': [
  237. // '.tmp/styles/{,*/}*.css'
  238. // ]
  239. // }
  240. // }
  241. // },
  242. // uglify: {
  243. // dist: {
  244. // files: {
  245. // '<%= yeoman.dist %>/scripts/scripts.js': [
  246. // '<%= yeoman.dist %>/scripts/scripts.js'
  247. // ]
  248. // }
  249. // }
  250. // },
  251. // concat: {
  252. // dist: {}
  253. // },
  254. imagemin: {
  255. dist: {
  256. files: [{
  257. expand: true,
  258. cwd: '<%= yeoman.app %>/images',
  259. src: '{,*/}*.{png,jpg,jpeg,gif}',
  260. dest: '<%= yeoman.dist %>/images'
  261. }]
  262. }
  263. },
  264. svgmin: {
  265. dist: {
  266. files: [{
  267. expand: true,
  268. cwd: '<%= yeoman.app %>/images',
  269. src: '{,*/}*.svg',
  270. dest: '<%= yeoman.dist %>/images'
  271. }]
  272. }
  273. },
  274. htmlmin: {
  275. dist: {
  276. options: {
  277. collapseWhitespace: true,
  278. conservativeCollapse: true,
  279. collapseBooleanAttributes: true,
  280. removeCommentsFromCDATA: true,
  281. removeOptionalTags: true
  282. },
  283. files: [{
  284. expand: true,
  285. cwd: '<%= yeoman.dist %>',
  286. src: ['*.html', 'views/{,*/}*.html'],
  287. dest: '<%= yeoman.dist %>'
  288. }]
  289. }
  290. },
  291. // ng-annotate tries to make the code safe for minification automatically
  292. // by using the Angular long form for dependency injection.
  293. ngAnnotate: {
  294. dist: {
  295. files: [{
  296. expand: true,
  297. cwd: '.tmp/concat/scripts',
  298. src: '*.js',
  299. dest: '.tmp/concat/scripts'
  300. }]
  301. }
  302. },
  303. // Replace Google CDN references
  304. cdnify: {
  305. dist: {
  306. html: ['<%= yeoman.dist %>/*.html']
  307. }
  308. },
  309. // Copies remaining files to places other tasks can use
  310. copy: {
  311. dist: {
  312. files: [{
  313. expand: true,
  314. dot: true,
  315. cwd: '<%= yeoman.app %>',
  316. dest: '<%= yeoman.dist %>',
  317. src: [
  318. '*.{ico,png,txt}',
  319. '.htaccess',
  320. '*.html',
  321. 'views/{,*/}*.html',
  322. 'images/{,*/}*.{webp}',
  323. 'styles/fonts/{,*/}*.*'
  324. ]
  325. }, {
  326. expand: true,
  327. cwd: '.tmp/images',
  328. dest: '<%= yeoman.dist %>/images',
  329. src: ['generated/*']
  330. }, {
  331. expand: true,
  332. cwd: 'bower_components/bootstrap/dist',
  333. src: 'fonts/*',
  334. dest: '<%= yeoman.dist %>'
  335. }]
  336. },
  337. styles: {
  338. expand: true,
  339. cwd: '<%= yeoman.app %>/styles',
  340. dest: '.tmp/styles/',
  341. src: '{,*/}*.css'
  342. }
  343. },
  344. // Run some tasks in parallel to speed up the build process
  345. concurrent: {
  346. server: [
  347. 'copy:styles'
  348. ],
  349. test: [
  350. 'copy:styles'
  351. ],
  352. dist: [
  353. 'copy:styles',
  354. 'imagemin',
  355. 'svgmin'
  356. ]
  357. },
  358. // Test settings
  359. karma: {
  360. unit: {
  361. configFile: 'test/karma.conf.js',
  362. singleRun: true
  363. }
  364. }
  365. });
  366. grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
  367. if (target === 'dist') {
  368. return grunt.task.run(['build', 'connect:dist:keepalive']);
  369. }
  370. grunt.task.run([
  371. 'clean:server',
  372. 'wiredep',
  373. 'concurrent:server',
  374. 'autoprefixer:server',
  375. 'connect:livereload',
  376. 'watch'
  377. ]);
  378. });
  379. grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
  380. grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
  381. grunt.task.run(['serve:' + target]);
  382. });
  383. grunt.registerTask('test', [
  384. 'clean:server',
  385. 'wiredep',
  386. 'concurrent:test',
  387. 'autoprefixer',
  388. 'connect:test',
  389. 'karma'
  390. ]);
  391. grunt.registerTask('build', [
  392. 'clean:dist',
  393. 'wiredep',
  394. 'useminPrepare',
  395. 'concurrent:dist',
  396. 'autoprefixer',
  397. 'concat',
  398. 'ngAnnotate',
  399. 'copy:dist',
  400. 'cdnify',
  401. 'cssmin',
  402. 'uglify',
  403. 'filerev',
  404. 'usemin',
  405. 'htmlmin'
  406. ]);
  407. grunt.registerTask('default', [
  408. 'newer:jshint',
  409. 'test',
  410. 'build'
  411. ]);
  412. };