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

/todomvc/root/grunt.js

https://github.com/backbone-boilerplate/init
JavaScript | 150 lines | 68 code | 23 blank | 59 comment | 1 complexity | 42d7d6ae20710a889e7e75dc94900744 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. //
  5. module.exports = function(grunt) {
  6. grunt.initConfig({
  7. // The clean task ensures all files are removed from the dist/ directory so
  8. // that no files linger from previous builds.
  9. clean: ["dist/"],
  10. // The lint task will run the build configuration and the application
  11. // JavaScript through JSHint and report any errors. You can change the
  12. // options for this task, by reading this:
  13. // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md
  14. lint: {
  15. files: [
  16. "build/config.js", "app/**/*.js"
  17. ]
  18. },
  19. // The jshint option for scripturl is set to lax, because the anchor
  20. // override inside main.js needs to test for them so as to not accidentally
  21. // route.
  22. jshint: {
  23. options: {
  24. scripturl: true
  25. }
  26. },
  27. // The jst task compiles all application templates into JavaScript
  28. // functions with the underscore.js template function from 1.2.4. You can
  29. // change the namespace and the template options, by reading this:
  30. // https://github.com/tbranyen/build-tasks/tree/master/jst
  31. //
  32. // The concat task depends on this file to exist, so if you decide to
  33. // remove this, ensure concat is updated accordingly.
  34. jst: {
  35. "dist/debug/templates.js": [
  36. "app/templates/**/*.html"
  37. ]
  38. },
  39. // The concatenate task is used here to merge the almond require/define
  40. // shim and the templates into the application code. It's named
  41. // dist/debug/require.js, because we want to only load one script file in
  42. // index.html.
  43. concat: {
  44. "dist/debug/require.js": [
  45. "assets/js/libs/almond.js",
  46. "dist/debug/templates.js",
  47. "dist/debug/require.js"
  48. ]
  49. },
  50. // This task uses the MinCSS Node.js project to take all your CSS files in
  51. // order and concatenate them into a single CSS file named index.css. It
  52. // also minifies all the CSS as well. This is named index.css, because we
  53. // only want to load one stylesheet in index.html.
  54. mincss: {
  55. "dist/release/index.css": [
  56. "assets/css/h5bp.css",
  57. "assets/css/style.css",
  58. "assets/css/todo.css"
  59. ]
  60. },
  61. // Takes the built require.js file and minifies it for filesize benefits.
  62. min: {
  63. "dist/release/require.js": [
  64. "dist/debug/require.js"
  65. ]
  66. },
  67. // Running the server without specifying an action will run the defaults,
  68. // port: 8080 and host: 127.0.0.1. If you would like to change these
  69. // defaults, simply add in the properties `port` and `host` respectively.
  70. //
  71. // Changing the defaults might look something like this:
  72. //
  73. // server: {
  74. // host: "127.0.0.1", port: 9001
  75. // debug: { ... can set host and port here too ...
  76. // }
  77. //
  78. // To learn more about using the server task, please refer to the code
  79. // until documentation has been written.
  80. server: {
  81. files: { "favicon.ico": "favicon.ico" },
  82. debug: {
  83. files: { "favicon.ico": "favicon.ico" },
  84. folders: {
  85. "app": "dist/debug",
  86. "assets/js/libs": "dist/debug"
  87. }
  88. },
  89. release: {
  90. // These two options make it easier for deploying, by using whatever
  91. // PORT is available in the environment and defaulting to any IP.
  92. host: "0.0.0.0",
  93. port: process.env.PORT || 8000,
  94. files: { "favicon.ico": "favicon.ico" },
  95. folders: {
  96. "app": "dist/release",
  97. "assets/js/libs": "dist/release",
  98. "assets/css": "dist/release"
  99. }
  100. }
  101. },
  102. // This task uses James Burke's excellent r.js AMD build tool. In the
  103. // future other builders may be contributed as drop-in alternatives.
  104. requirejs: {
  105. // Include the main configuration file
  106. mainConfigFile: "app/config.js",
  107. // Output file
  108. out: "dist/debug/require.js",
  109. // Root application module
  110. name: "config",
  111. // Do not wrap everything in an IIFE
  112. wrap: false
  113. }
  114. });
  115. // The default task will remove all contents inside the dist/ folder, lint
  116. // all your code, precompile all the underscore templates into
  117. // dist/debug/templates.js, compile all the application code into
  118. // dist/debug/require.js, and then concatenate the require/define shim
  119. // almond.js and dist/debug/templates.js into the require.js file.
  120. grunt.registerTask("default", "clean lint jst requirejs concat");
  121. // The debug task is simply an alias to default to remain consistent with
  122. // debug/release.
  123. grunt.registerTask("debug", "default");
  124. // The release task will run the debug tasks and then minify the
  125. // dist/debug/require.js file and CSS files.
  126. grunt.registerTask("release", "default min mincss");
  127. };