Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. 'use strict';
  2.  
  3. module.exports = function(grunt) {
  4. // Unified Watch Object
  5. var watchFiles = {
  6. serverViews: ['app/views/**/*.*'],
  7. serverJS: ['gruntfile.js', 'server.js', 'config/**/*.js', 'app/**/*.js'],
  8. clientViews: ['public/modules/**/views/**/*.html'],
  9. clientJS: ['public/js/*.js', 'public/modules/**/*.js'],
  10. clientCSS: ['public/modules/**/*.css'],
  11. mochaTests: ['app/tests/**/*.js']
  12. };
  13.  
  14. // Project Configuration
  15. grunt.initConfig({
  16. pkg: grunt.file.readJSON('package.json'),
  17. watch: {
  18. options: { livereload: true },
  19. serverViews: {
  20. files: [watchFiles.serverViews],
  21. options: {
  22. livereload: true
  23. }
  24. },
  25. serverJS: {
  26. files: watchFiles.serverJS,
  27. tasks: ['jshint'],
  28. options: {
  29. livereload: true
  30. }
  31. },
  32. clientViews: {
  33. files: watchFiles.clientViews,
  34. options: {
  35. livereload: true,
  36. }
  37. },
  38. clientJS: {
  39. files: watchFiles.clientJS,
  40. tasks: ['jshint'],
  41. options: {
  42. livereload: true
  43. }
  44. },
  45. clientCSS: {
  46. files: watchFiles.clientCSS,
  47. tasks: ['csslint'],
  48. options: {
  49. livereload: true
  50. }
  51. }
  52. },
  53. jshint: {
  54. all: {
  55. src: watchFiles.clientJS.concat(watchFiles.serverJS),
  56. options: {
  57. jshintrc: true
  58. }
  59. }
  60. },
  61. csslint: {
  62. options: {
  63. csslintrc: '.csslintrc',
  64. },
  65. all: {
  66. src: watchFiles.clientCSS
  67. }
  68. },
  69. uglify: {
  70. production: {
  71. options: {
  72. mangle: false
  73. },
  74. files: {
  75. 'public/dist/application.min.js': 'public/dist/application.js'
  76. }
  77. }
  78. },
  79. cssmin: {
  80. combine: {
  81. files: {
  82. 'public/dist/application.min.css': '<%= applicationCSSFiles %>'
  83. }
  84. }
  85. },
  86. nodemon: {
  87. dev: {
  88. script: 'server.js',
  89. options: {
  90. nodeArgs: ['--debug'],
  91. ext: 'js,html',
  92. watch: watchFiles.serverViews.concat(watchFiles.serverJS)
  93. }
  94. }
  95. },
  96. 'node-inspector': {
  97. custom: {
  98. options: {
  99. 'web-port': 1337,
  100. 'web-host': 'localhost',
  101. 'debug-port': 5858,
  102. 'save-live-edit': true,
  103. 'no-preload': true,
  104. 'stack-trace-limit': 50,
  105. 'hidden': []
  106. }
  107. }
  108. },
  109. ngAnnotate: {
  110. production: {
  111. files: {
  112. 'public/dist/application.js': '<%= applicationJavaScriptFiles %>'
  113. }
  114. }
  115. },
  116. concurrent: {
  117. default: ['nodemon', 'watch'],
  118. debug: ['nodemon', 'watch', 'node-inspector'],
  119. options: {
  120. logConcurrentOutput: true,
  121. limit: 10
  122. }
  123. },
  124. env: {
  125. test: {
  126. NODE_ENV: 'test'
  127. }
  128. },
  129. mochaTest: {
  130. src: watchFiles.mochaTests,
  131. options: {
  132. reporter: 'spec',
  133. require: 'server.js'
  134. }
  135. },
  136. karma: {
  137. unit: {
  138. configFile: 'karma.conf.js'
  139. }
  140. }
  141. });
  142.  
  143. // Load NPM tasks
  144. require('load-grunt-tasks')(grunt);
  145.  
  146. // Making grunt default to force in order not to break the project.
  147. grunt.option('force', true);
  148.  
  149. // A Task for loading the configuration object
  150. grunt.task.registerTask('loadConfig', 'Task that loads the config into a grunt option.', function() {
  151. var init = require('./config/init')();
  152. var config = require('./config/config');
  153.  
  154. grunt.config.set('applicationJavaScriptFiles', config.assets.js);
  155. grunt.config.set('applicationCSSFiles', config.assets.css);
  156. });
  157.  
  158. // Default task(s).
  159. grunt.registerTask('default', ['lint', 'concurrent:default']);
  160.  
  161. // Debug task.
  162. grunt.registerTask('debug', ['lint', 'concurrent:debug']);
  163.  
  164. // Lint task(s).
  165. grunt.registerTask('lint', ['jshint', 'csslint']);
  166.  
  167. // Build task(s).
  168. grunt.registerTask('build', ['lint', 'loadConfig', 'ngAnnotate', 'uglify', 'cssmin']);
  169.  
  170. // Test task.
  171. grunt.registerTask('test', ['env:test', 'mochaTest', 'karma:unit']);
  172. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement