Gruntfile.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * grunt-browser-sync
  3. * https://github.com/shakyshane/grunt-browser-sync
  4. *
  5. * Copyright (c) 2013 Shane Osbourne
  6. * Licensed under the MIT license.
  7. */
  8. 'use strict';
  9. module.exports = function (grunt) {
  10. // Project configuration.
  11. grunt.initConfig({
  12. jshint: {
  13. all: [
  14. 'Gruntfile.js',
  15. 'tasks/*.js',
  16. '<%= nodeunit.tests %>'
  17. ],
  18. options: {
  19. jshintrc: '.jshintrc'
  20. }
  21. },
  22. uglify: {
  23. files: {
  24. src: "tasks/lib/style-injector-client.js",
  25. dest: "tasks/lib/style-injector-client.min.js"
  26. }
  27. },
  28. clean: {
  29. tests: ['tmp']
  30. },
  31. // The actual grunt server settings
  32. connect: {
  33. server: {
  34. options: {
  35. hostname: "127.0.0.1",
  36. port: 9001,
  37. base: "test/fixtures"
  38. }
  39. }
  40. },
  41. watch: {
  42. options: {
  43. spawn: false
  44. },
  45. server_tests: {
  46. files: [
  47. "test/new-server/**/*.js",
  48. "tasks/lib/**/*.js"
  49. ],
  50. tasks: ["jasmine_node"]
  51. },
  52. sass: {
  53. files: "test/fixtures/sass/*.scss",
  54. tasks: ['bsNotify:sassStart', 'sass', 'autoprefixer', 'bsReload:css']
  55. }
  56. },
  57. concurrent: {
  58. dev: {
  59. tasks: [
  60. 'watch',
  61. 'browserSync'
  62. ],
  63. options: {
  64. logConcurrentOutput: true
  65. }
  66. }
  67. },
  68. autoprefixer: {
  69. sass: {
  70. files: {
  71. "test/fixtures/css/style.css": "test/fixtures/css/style.css"
  72. }
  73. }
  74. },
  75. browserSync: {
  76. server: {
  77. bsFiles: {
  78. src : [
  79. //'test/fixtures/css/*.css',
  80. 'test/fixtures/*.html'
  81. ]
  82. },
  83. options: {
  84. open: false,
  85. online: false,
  86. background: true,
  87. server: {
  88. baseDir: ["test/fixtures", "test/fixtures2"],
  89. middleware: [
  90. function (req, res, next) {
  91. console.log("from middleware 1");
  92. next();
  93. },
  94. function (req, res, next) {
  95. console.log("from middleware 2");
  96. next();
  97. }
  98. ]
  99. }
  100. }
  101. },
  102. proxy: {
  103. files: {
  104. src : [
  105. 'test/fixtures/css/style.css'
  106. ]
  107. },
  108. options: {
  109. watchTask: false,
  110. debugInfo: true,
  111. ghostMode: {
  112. scroll: true,
  113. links: true,
  114. forms: true
  115. },
  116. proxy: {
  117. host: "127.0.0.1",
  118. port: 9001
  119. }
  120. }
  121. }
  122. },
  123. "bsReload": {
  124. css: {
  125. reload: "style.css"
  126. },
  127. all: {
  128. reload: true
  129. }
  130. },
  131. "bsNotify": {
  132. sassStart: {
  133. notify: "Please wait, compiling sass!"
  134. }
  135. },
  136. sass: {
  137. test: {
  138. files: {
  139. "test/fixtures/css/style.css" : "test/fixtures/sass/style.scss"
  140. }
  141. }
  142. },
  143. karma: {
  144. unit: {
  145. configFile: 'test/karma.conf.js',
  146. singleRun: true
  147. }
  148. },
  149. nodeunit: {
  150. tests: ['test/*_test.js']
  151. }
  152. });
  153. // Actually load this plugin's task(s).
  154. grunt.loadTasks('tasks');
  155. grunt.loadNpmTasks('grunt-contrib-sass');
  156. //grunt.loadNpmTasks('grunt-sass');
  157. grunt.loadNpmTasks('grunt-contrib-watch');
  158. grunt.loadNpmTasks('grunt-autoprefixer');
  159. grunt.loadNpmTasks('grunt-contrib-connect');
  160. grunt.loadNpmTasks('grunt-concurrent');
  161. // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  162. // plugin's task(s), then test the result.
  163. grunt.registerTask('test', ['karma', 'jasmine_node']);
  164. // By default, lint and run all tests.
  165. grunt.registerTask('default', ["browserSync"]);
  166. grunt.registerTask('dev-watch', ["browserSync:server", "watch:sass"]);
  167. grunt.registerTask('server', ["browserSync:server", "watch:sass"]);
  168. grunt.registerTask('proxy', ["browserSync:proxy", "watch:sass"]);
  169. grunt.registerTask('server-proxy', ["connect", "browserSync:proxy"]);
  170. };