PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/public/grunt.js

https://bitbucket.org/nomospace/waybo
JavaScript | 207 lines | 89 code | 31 blank | 87 comment | 0 complexity | a4652ed5972fe2e8ffd5193584d3b969 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. "dist/debug/index.css"
  71. ]
  72. },
  73. // This task simplifies working with CSS inside Backbone Boilerplate
  74. // projects. Instead of manually specifying your stylesheets inside the
  75. // configuration, you can use `@imports` and this task will concatenate
  76. // only those paths.
  77. styles: {
  78. // Out the concatenated contents of the following styles into the below
  79. // development file path.
  80. "dist/debug/index.css": {
  81. // Point this to where your `index.css` file is location.
  82. src: "assets/css/index.css",
  83. // The relative path to use for the @imports.
  84. paths: ["assets/css"],
  85. // Additional production-only stylesheets here.
  86. additional: []
  87. }
  88. },
  89. // Takes the built require.js file and minifies it for filesize benefits.
  90. min: {
  91. "dist/release/require.js": [
  92. "dist/debug/require.js"
  93. ]
  94. },
  95. // Running the server without specifying an action will run the defaults,
  96. // port: 8000 and host: 127.0.0.1. If you would like to change these
  97. // defaults, simply add in the properties `port` and `host` respectively.
  98. // Alternatively you can omit the port and host properties and the server
  99. // task will instead default to process.env.PORT or process.env.HOST.
  100. //
  101. // Changing the defaults might look something like this:
  102. //
  103. // server: {
  104. // host: "127.0.0.1", port: 9001
  105. // debug: { ... can set host and port here too ...
  106. // }
  107. //
  108. // To learn more about using the server task, please refer to the code
  109. // until documentation has been written.
  110. server: {
  111. // Ensure the favicon is mapped correctly.
  112. files: { "favicon.ico": "favicon.ico" },
  113. debug: {
  114. // Ensure the favicon is mapped correctly.
  115. files: { "favicon.ico": "favicon.ico" },
  116. // Map `server:debug` to `debug` folders.
  117. folders: {
  118. "app": "dist/debug",
  119. "assets/js/libs": "dist/debug",
  120. "assets/css": "dist/debug"
  121. }
  122. },
  123. release: {
  124. // This makes it easier for deploying, by defaulting to any IP.
  125. host: "0.0.0.0",
  126. // Ensure the favicon is mapped correctly.
  127. files: { "favicon.ico": "favicon.ico" },
  128. // Map `server:release` to `release` folders.
  129. folders: {
  130. "app": "dist/release",
  131. "assets/js/libs": "dist/release",
  132. "assets/css": "dist/release"
  133. }
  134. }
  135. },
  136. // This task uses James Burke's excellent r.js AMD build tool. In the
  137. // future other builders may be contributed as drop-in alternatives.
  138. requirejs: {
  139. // Include the main configuration file.
  140. mainConfigFile: "app/config.js",
  141. // Output file.
  142. out: "dist/debug/require.js",
  143. // Root application module.
  144. name: "config",
  145. // Do not wrap everything in an IIFE.
  146. wrap: false
  147. },
  148. // The headless QUnit testing environment is provided for "free" by Grunt.
  149. // Simply point the configuration to your test directory.
  150. qunit: {
  151. all: ["test/qunit/*.html"]
  152. },
  153. // The headless Jasmine testing is provided by grunt-jasmine-task. Simply
  154. // point the configuration to your test directory.
  155. jasmine: {
  156. all: ["test/jasmine/*.html"]
  157. },
  158. // The watch task can be used to monitor the filesystem and execute
  159. // specific tasks when files are modified. By default, the watch task is
  160. // available to compile CSS if you are unable to use the runtime compiler
  161. // (use if you have a custom server, PhoneGap, Adobe Air, etc.)
  162. watch: {
  163. files: ["grunt.js", "assets/**/*", "app/**/*"],
  164. tasks: "styles"
  165. }
  166. });
  167. // The debug task will remove all contents inside the dist/ folder, lint
  168. // all your code, precompile all the underscore templates into
  169. // dist/debug/templates.js, compile all the application code into
  170. // dist/debug/require.js, and then concatenate the require/define shim
  171. // almond.js and dist/debug/templates.js into the require.js file.
  172. grunt.registerTask("debug", "clean lint jst requirejs concat styles");
  173. // The release task will run the debug tasks and then minify the
  174. // dist/debug/require.js file and CSS files.
  175. grunt.registerTask("release", "debug min mincss");
  176. };