PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/grunt.js

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