gruntfile.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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']
  24. }
  25. },
  26. watch: {
  27. options: {
  28. nospawn: true
  29. },
  30. dev: {
  31. files: ['src/**/*.js'],
  32. tasks: ['dev']
  33. }
  34. },
  35. karma: {
  36. options: {
  37. frameworks: ['jasmine', 'commonjs'],
  38. files: [
  39. 'src/**/*.js',
  40. 'test/unit/specs/**/*.js'
  41. ],
  42. preprocessors: {
  43. 'src/**/*.js': ['commonjs'],
  44. 'test/unit/specs/**/*.js': ['commonjs']
  45. },
  46. singleRun: true
  47. },
  48. browsers: {
  49. options: {
  50. browsers: ['Chrome', 'Firefox'],
  51. reporters: ['progress']
  52. }
  53. },
  54. phantom: {
  55. options: {
  56. browsers: ['PhantomJS'],
  57. reporters: ['progress', 'coverage'],
  58. preprocessors: {
  59. 'src/**/*.js': ['commonjs', 'coverage'],
  60. 'test/unit/specs/**/*.js': ['commonjs']
  61. },
  62. coverageReporter: {
  63. reporters: [
  64. { type: 'lcov' },
  65. { type: 'text-summary' }
  66. ]
  67. }
  68. }
  69. }
  70. }
  71. })
  72. // load npm tasks
  73. grunt.loadNpmTasks('grunt-contrib-jshint')
  74. grunt.loadNpmTasks('grunt-contrib-watch')
  75. grunt.loadNpmTasks('grunt-karma')
  76. // load custom tasks
  77. grunt.file.recurse('grunt/tasks', function (path) {
  78. require('./' + path)(grunt)
  79. })
  80. grunt.registerTask('unit', ['karma:browsers'])
  81. grunt.registerTask('cover', ['karma:phantom'])
  82. grunt.registerTask('test', ['unit', 'cover'])
  83. grunt.registerTask('default', ['jshint', 'test', 'build'])
  84. }