PageRenderTime 29ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/tutorial/root/grunt.js

https://github.com/backbone-boilerplate/init
JavaScript | 149 lines | 67 code | 23 blank | 59 comment | 1 complexity | afa0fc023652e85fffc42eba8e6bedcc 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. ]
  59. },
  60. // Takes the built require.js file and minifies it for filesize benefits.
  61. min: {
  62. "dist/release/require.js": [
  63. "dist/debug/require.js"
  64. ]
  65. },
  66. // Running the server without specifying an action will run the defaults,
  67. // port: 8080 and host: 127.0.0.1. If you would like to change these
  68. // defaults, simply add in the properties `port` and `host` respectively.
  69. //
  70. // Changing the defaults might look something like this:
  71. //
  72. // server: {
  73. // host: "127.0.0.1", port: 9001
  74. // debug: { ... can set host and port here too ...
  75. // }
  76. //
  77. // To learn more about using the server task, please refer to the code
  78. // until documentation has been written.
  79. server: {
  80. files: { "favicon.ico": "favicon.ico" },
  81. debug: {
  82. files: { "favicon.ico": "favicon.ico" },
  83. folders: {
  84. "app": "dist/debug",
  85. "assets/js/libs": "dist/debug"
  86. }
  87. },
  88. release: {
  89. // These two options make it easier for deploying, by using whatever
  90. // PORT is available in the environment and defaulting to any IP.
  91. host: "0.0.0.0",
  92. port: process.env.PORT || 8000,
  93. files: { "favicon.ico": "favicon.ico" },
  94. folders: {
  95. "app": "dist/release",
  96. "assets/js/libs": "dist/release",
  97. "assets/css": "dist/release"
  98. }
  99. }
  100. },
  101. // This task uses James Burke's excellent r.js AMD build tool. In the
  102. // future other builders may be contributed as drop-in alternatives.
  103. requirejs: {
  104. // Include the main configuration file
  105. mainConfigFile: "app/config.js",
  106. // Output file
  107. out: "dist/debug/require.js",
  108. // Root application module
  109. name: "config",
  110. // Do not wrap everything in an IIFE
  111. wrap: false
  112. }
  113. });
  114. // The default task will remove all contents inside the dist/ folder, lint
  115. // all your code, precompile all the underscore templates into
  116. // dist/debug/templates.js, compile all the application code into
  117. // dist/debug/require.js, and then concatenate the require/define shim
  118. // almond.js and dist/debug/templates.js into the require.js file.
  119. grunt.registerTask("default", "clean lint jst requirejs concat");
  120. // The debug task is simply an alias to default to remain consistent with
  121. // debug/release.
  122. grunt.registerTask("debug", "default");
  123. // The release task will run the debug tasks and then minify the
  124. // dist/debug/require.js file and CSS files.
  125. grunt.registerTask("release", "default min mincss");
  126. };