gruntfile.js 2.2 KB

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