gruntfile.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. var sauceConfig = require('./grunt/sauce')
  2. module.exports = function (grunt) {
  3. var version = grunt.file.readJSON('package.json').version
  4. var banner =
  5. '/**\n' +
  6. ' * Vue.js v' + version + '\n' +
  7. ' * (c) ' + new Date().getFullYear() + ' Evan You\n' +
  8. ' * Released under the MIT License.\n' +
  9. ' */\n'
  10. grunt.initConfig({
  11. banner: banner,
  12. jshint: {
  13. options: {
  14. reporter: require('jshint-stylish'),
  15. jshintrc: true
  16. },
  17. build: {
  18. src: ['gruntfile.js', 'tasks/*.js']
  19. },
  20. src: {
  21. src: 'src/**/*.js'
  22. },
  23. test: {
  24. src: ['test/unit/specs/**/*.js', 'test/e2e/*.js']
  25. }
  26. },
  27. watch: {
  28. options: {
  29. nospawn: true
  30. },
  31. dev: {
  32. files: ['src/**/*.js'],
  33. tasks: ['dev']
  34. },
  35. test: {
  36. files: ['test/unit/specs/**/*.js'],
  37. tasks: ['build-test']
  38. }
  39. },
  40. karma: {
  41. options: {
  42. frameworks: ['jasmine', 'commonjs'],
  43. files: [
  44. 'src/**/*.js',
  45. 'test/unit/specs/**/*.js'
  46. ],
  47. preprocessors: {
  48. 'src/**/*.js': ['commonjs'],
  49. 'test/unit/specs/**/*.js': ['commonjs']
  50. },
  51. singleRun: true
  52. },
  53. browsers: {
  54. options: {
  55. browsers: ['Chrome', 'Firefox'],
  56. reporters: ['progress']
  57. }
  58. },
  59. coverage: {
  60. options: {
  61. browsers: ['PhantomJS'],
  62. reporters: ['progress', 'coverage'],
  63. preprocessors: {
  64. 'src/**/*.js': ['commonjs', 'coverage'],
  65. 'test/unit/specs/**/*.js': ['commonjs']
  66. },
  67. coverageReporter: {
  68. reporters: [
  69. { type: 'lcov' },
  70. { type: 'text-summary' }
  71. ]
  72. }
  73. }
  74. },
  75. sauce1: {
  76. options: sauceConfig.batch1
  77. },
  78. sauce2: {
  79. options: sauceConfig.batch2
  80. },
  81. sauce3: {
  82. options: sauceConfig.batch3
  83. }
  84. },
  85. coveralls: {
  86. options: {
  87. coverage_dir: 'coverage/',
  88. force: true
  89. }
  90. }
  91. })
  92. // load npm tasks
  93. grunt.loadNpmTasks('grunt-contrib-jshint')
  94. grunt.loadNpmTasks('grunt-contrib-watch')
  95. grunt.loadNpmTasks('grunt-karma')
  96. grunt.loadNpmTasks('grunt-karma-coveralls')
  97. // load custom tasks
  98. grunt.file.recurse('grunt/tasks', function (path) {
  99. require('./' + path)(grunt)
  100. })
  101. grunt.registerTask('unit', ['karma:browsers'])
  102. grunt.registerTask('cover', ['karma:coverage'])
  103. grunt.registerTask('test', ['unit', 'cover', 'casper'])
  104. grunt.registerTask('sauce', ['karma:sauce1', 'karma:sauce2', 'karma:sauce3'])
  105. grunt.registerTask('ci', ['jshint', 'test', 'coveralls', 'sauce'])
  106. grunt.registerTask('default', ['jshint', 'test', 'build'])
  107. }