/grunt.js

https://github.com/newshour/map_center · JavaScript · 181 lines · 167 code · 4 blank · 10 comment · 3 complexity · c95a864e7422ceaf4d646682fd39ab86 MD5 · raw file

  1. /*global module:false*/
  2. module.exports = function(grunt) {
  3. // Project configuration.
  4. grunt.initConfig({
  5. pkg: "<json:package.json>",
  6. meta: {
  7. NODE_HOST: process.env.NODE_HOST || "127.0.0.1",
  8. NODE_PORT: process.env.NODE_PORT || 8000,
  9. banner: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
  10. "<%= grunt.template.today('yyyy-mm-dd') %>\n" +
  11. "<%= pkg.homepage ? '* ' + pkg.homepage + '\n' : '' %>" +
  12. "* Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author %>; */"
  13. },
  14. lint: {
  15. server: [
  16. "grunt.js",
  17. "backend/*.js",
  18. "backend/stress/client/*.js"
  19. ],
  20. client: [
  21. "backend/www/scripts/app.js",
  22. "backend/www/scripts/modules/*.js",
  23. "frontend/scripts/*.js",
  24. "shared/*.js"
  25. ]
  26. },
  27. // Compile Underscore.js-compatable templates into JavaScript functions for
  28. // run-time efficiency and simplified maintenance
  29. jst: {
  30. adminapp: {
  31. options: {
  32. namespace: "JST"
  33. },
  34. files: {
  35. "backend/www/scripts/jst.js": "backend/templates/*.html"
  36. }
  37. }
  38. },
  39. qunit: {
  40. all: ["frontend/test/index.html"]
  41. },
  42. test: {
  43. "backend": ["backend/test/*.js"]
  44. },
  45. requirejs: {
  46. "adminapp": {
  47. options: {
  48. mainConfigFile: "backend/www/scripts/main-config.js"
  49. }
  50. }
  51. },
  52. copy: {
  53. // This copy target should only be run in development as it inserts
  54. // require.js in the application's position, thus allowing dependencies
  55. // to be resolved at run time.
  56. "adminapp-dev": {
  57. options: {
  58. processName: function(fileName) {
  59. if (/require.*\.js$/i.test(fileName)) {
  60. fileName = "require.js";
  61. }
  62. return fileName;
  63. }
  64. },
  65. files: {
  66. "backend/www/scripts/": "backend/www/scripts/lib/require-2.0.6.js"
  67. }
  68. },
  69. "adminapp": {
  70. options: {
  71. flatten: true,
  72. // Inject NODE_HOST and NODE_PORT values into files as they are
  73. // copied
  74. processContent: function(content) {
  75. return content.replace(/\{\{\s*(NODE_HOST|NODE_PORT)\s*\}\}/g,
  76. function(match, varName) {
  77. return grunt.config("meta." + varName);
  78. }
  79. );
  80. }
  81. },
  82. files: {
  83. "backend/www/scripts/shared": [
  84. "shared/livemap_status.js",
  85. "shared/livemap_popcorn.js",
  86. "shared/livemap_connection.js"
  87. ],
  88. "backend/www/scripts/shared/lib": "shared/lib/*",
  89. "frontend/dist/lib/map_center/modules/shared": [
  90. "shared/livemap_status.js",
  91. "shared/livemap_popcorn.js",
  92. "shared/livemap_connection.js"
  93. ],
  94. "frontend/dist/lib/map_center/modules/shared/lib": "shared/lib/*"
  95. }
  96. }
  97. },
  98. concat: {
  99. dist: {
  100. src: [
  101. "frontend/dist/lib/map_center/modules/shared/lib/*.js",
  102. "frontend/dist/lib/map_center/modules/shared/livemap_status.js",
  103. "frontend/dist/lib/map_center/modules/shared/livemap_connection.js",
  104. "frontend/dist/lib/map_center/modules/shared/livemap_popcorn.js",
  105. "frontend/scripts/ui_realtime.js"
  106. ],
  107. dest: "frontend/dist/lib/map_center/modules/livemap.js"
  108. },
  109. playback: {
  110. src: [
  111. "frontend/dist/lib/map_center/modules/shared/lib/popcorn*.js",
  112. "frontend/dist/lib/map_center/modules/shared/livemap_status.js",
  113. "frontend/dist/lib/map_center/modules/shared/livemap_popcorn.js",
  114. "frontend/scripts/ui_playback.js"
  115. ],
  116. dest: "frontend/dist/lib/map_center/modules/livemap-playback.js"
  117. }
  118. },
  119. min: {
  120. dist: {
  121. src: ["<banner:meta.banner>", "<config:concat.dist.dest>"],
  122. dest: "<config:concat.dist.dest>"
  123. },
  124. playback: {
  125. src: ["<banner:meta.banner>", "<config:concat.playback.dest>"],
  126. dest: "<config:concat.playback.dest>"
  127. }
  128. },
  129. watch: {
  130. files: "<config:lint.files>",
  131. tasks: "lint"
  132. },
  133. jshint: {
  134. server: {
  135. options: {
  136. curly: true,
  137. eqeqeq: true,
  138. immed: true,
  139. latedef: true,
  140. newcap: true,
  141. noarg: true,
  142. sub: true,
  143. undef: true,
  144. boss: true,
  145. eqnull: true,
  146. node: true,
  147. es5: true
  148. }
  149. },
  150. client: {
  151. options: {
  152. curly: true,
  153. eqeqeq: true,
  154. immed: true,
  155. latedef: true,
  156. newcap: true,
  157. noarg: true,
  158. sub: true,
  159. undef: true,
  160. boss: true,
  161. eqnull: true,
  162. browser: true
  163. },
  164. globals: {
  165. console: true,
  166. require: true,
  167. define: true
  168. }
  169. }
  170. },
  171. uglify: {}
  172. });
  173. grunt.loadNpmTasks("grunt-contrib");
  174. // Default task.
  175. grunt.registerTask("default", "lint test concat min jst copy:adminapp requirejs");
  176. grunt.registerTask("dev", "lint test concat jst copy");
  177. };