PageRenderTime 55ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/grunt.js

https://github.com/madhums/geekhunt
JavaScript | 212 lines | 94 code | 31 blank | 87 comment | 0 complexity | 64ce558e5e2c4a432a079abdd3a2123b MD5 | raw file
  1. // This is the main application configuration file. It is a Grunt
  2. // configuration file, which you can learn more about here:
  3. // https://github.com/cowboy/grunt/blob/master/docs/configuring.md
  4. module.exports = function(grunt) {
  5. grunt.initConfig({
  6. // The clean task ensures all files are removed from the dist/ directory so
  7. // that no files linger from previous builds.
  8. clean: ["dist/"],
  9. // The lint task will run the build configuration and the application
  10. // JavaScript through JSHint and report any errors. You can change the
  11. // options for this task, by reading this:
  12. // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md
  13. lint: {
  14. files: [
  15. "build/config.js", "app/**/*.js"
  16. ]
  17. },
  18. // The jshint option for scripturl is set to lax, because the anchor
  19. // override inside main.js needs to test for them so as to not accidentally
  20. // route.
  21. jshint: {
  22. options: {
  23. scripturl: true
  24. }
  25. },
  26. // The jst task compiles all application templates into JavaScript
  27. // functions with the underscore.js template function from 1.2.4. You can
  28. // change the namespace and the template options, by reading this:
  29. // https://github.com/gruntjs/grunt-contrib/blob/master/docs/jst.md
  30. //
  31. // The concat task depends on this file to exist, so if you decide to
  32. // remove this, ensure concat is updated accordingly.
  33. jst: {
  34. "dist/debug/templates.js": [
  35. "app/templates/**/*.html"
  36. ]
  37. },
  38. // The handlebars task compiles all application templates into JavaScript
  39. // functions using Handlebars templating engine.
  40. //
  41. // Since this task defaults to writing to the same file as the jst task,
  42. // edit the debug task replacing jst with handlebars.
  43. //
  44. // The concat task depends on this file to exist, so if you decide to
  45. // remove this, ensure concat is updated accordingly.
  46. handlebars: {
  47. "dist/debug/templates.js": ["app/templates/**/*.html"]
  48. },
  49. // The concatenate task is used here to merge the almond require/define
  50. // shim and the templates into the application code. It's named
  51. // dist/debug/require.js, because we want to only load one script file in
  52. // index.html.
  53. concat: {
  54. dist: {
  55. src: [
  56. "assets/js/libs/almond.js",
  57. "dist/debug/templates.js",
  58. "dist/debug/require.js"
  59. ],
  60. dest: "dist/debug/require.js",
  61. separator: ";"
  62. }
  63. },
  64. // This task uses the MinCSS Node.js project to take all your CSS files in
  65. // order and concatenate them into a single CSS file named index.css. It
  66. // also minifies all the CSS as well. This is named index.css, because we
  67. // only want to load one stylesheet in index.html.
  68. mincss: {
  69. "dist/release/index.css": [
  70. "assets/css/index.css",
  71. "assets/vendor/htbp/css/style.css",
  72. "assets/vendor/bootstrap/css/bootstrap.css",
  73. "assets/vendor/bootstrap/css/bootstrap-responsive.css",
  74. ]
  75. },
  76. // This task simplifies working with CSS inside Backbone Boilerplate
  77. // projects. Instead of manually specifying your stylesheets inside the
  78. // configuration, you can use `@imports` and this task will concatenate
  79. // only those paths.
  80. styles: {
  81. // Out the concatenated contents of the following styles into the below
  82. // development file path.
  83. "dist/debug/index.css": {
  84. // Point this to where your `index.css` file is location.
  85. src: "assets/css/index.css",
  86. // The relative path to use for the @imports.
  87. paths: ["assets/css", "assets/vendor/bootstrap/css"],
  88. // Additional production-only stylesheets here.
  89. additional: []
  90. }
  91. },
  92. // Takes the built require.js file and minifies it for filesize benefits.
  93. min: {
  94. "dist/release/require.js": [
  95. "dist/debug/require.js"
  96. ]
  97. },
  98. // Running the server without specifying an action will run the defaults,
  99. // port: 8000 and host: 127.0.0.1. If you would like to change these
  100. // defaults, simply add in the properties `port` and `host` respectively.
  101. // Alternatively you can omit the port and host properties and the server
  102. // task will instead default to process.env.PORT or process.env.HOST.
  103. //
  104. // Changing the defaults might look something like this:
  105. //
  106. // server: {
  107. // host: "127.0.0.1", port: 9001
  108. // debug: { ... can set host and port here too ...
  109. // }
  110. //
  111. // To learn more about using the server task, please refer to the code
  112. // until documentation has been written.
  113. server: {
  114. host: "0.0.0.0",
  115. port: process.env.PORT,
  116. // Ensure the favicon is mapped correctly.
  117. files: { "favicon.ico": "favicon.ico" },
  118. debug: {
  119. // Ensure the favicon is mapped correctly.
  120. files: { "favicon.ico": "favicon.ico" },
  121. // Map `server:debug` to `debug` folders.
  122. folders: {
  123. "app": "dist/debug",
  124. "assets/js/libs": "dist/debug",
  125. "assets/css": "dist/debug"
  126. }
  127. },
  128. release: {
  129. // This makes it easier for deploying, by defaulting to any IP.
  130. host: "0.0.0.0",
  131. // Ensure the favicon is mapped correctly.
  132. files: { "favicon.ico": "favicon.ico" },
  133. // Map `server:release` to `release` folders.
  134. folders: {
  135. "app": "dist/release",
  136. "assets/js/libs": "dist/release",
  137. "assets/css": "dist/release"
  138. }
  139. }
  140. },
  141. // This task uses James Burke's excellent r.js AMD build tool. In the
  142. // future other builders may be contributed as drop-in alternatives.
  143. requirejs: {
  144. // Include the main configuration file.
  145. mainConfigFile: "app/config.js",
  146. // Output file.
  147. out: "dist/debug/require.js",
  148. // Root application module.
  149. name: "config",
  150. // Do not wrap everything in an IIFE.
  151. wrap: false
  152. },
  153. // The headless QUnit testing environment is provided for "free" by Grunt.
  154. // Simply point the configuration to your test directory.
  155. qunit: {
  156. all: ["test/qunit/*.html"]
  157. },
  158. // The headless Jasmine testing is provided by grunt-jasmine-task. Simply
  159. // point the configuration to your test directory.
  160. jasmine: {
  161. all: ["test/jasmine/*.html"]
  162. },
  163. // The watch task can be used to monitor the filesystem and execute
  164. // specific tasks when files are modified. By default, the watch task is
  165. // available to compile CSS if you are unable to use the runtime compiler
  166. // (use if you have a custom server, PhoneGap, Adobe Air, etc.)
  167. watch: {
  168. files: ["grunt.js", "assets/**/*", "app/**/*"],
  169. tasks: "styles"
  170. }
  171. });
  172. // The debug task will remove all contents inside the dist/ folder, lint
  173. // all your code, precompile all the underscore templates into
  174. // dist/debug/templates.js, compile all the application code into
  175. // dist/debug/require.js, and then concatenate the require/define shim
  176. // almond.js and dist/debug/templates.js into the require.js file.
  177. grunt.registerTask("debug", "clean lint jst requirejs concat");
  178. // The release task will run the debug tasks and then minify the
  179. // dist/debug/require.js file and CSS files.
  180. grunt.registerTask("release", "debug min mincss");
  181. };