Gruntfile.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* jshint node: true */
  2. module.exports = function(grunt) {
  3. "use strict";
  4. // Project configuration.
  5. grunt.initConfig({
  6. // Metadata.
  7. pkg: grunt.file.readJSON('package.json'),
  8. banner: '/*!\n' +
  9. ' * Validator v<%= pkg.version %> for Bootstrap 3, by @1000hz\n' +
  10. ' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
  11. ' * Licensed under <%= _.pluck(pkg.licenses, "url").join(", ") %>\n' +
  12. ' *\n' +
  13. ' * https://github.com/1000hz/bootstrap-validator\n' +
  14. ' */\n\n',
  15. // Task configuration.
  16. jshint: {
  17. options: {
  18. jshintrc: 'js/.jshintrc'
  19. },
  20. gruntfile: {
  21. src: 'Gruntfile.js'
  22. },
  23. src: {
  24. src: ['js/*.js']
  25. },
  26. test: {
  27. src: ['js/tests/unit/*.js']
  28. }
  29. },
  30. concat: {
  31. options: {
  32. banner: '<%= banner %>',
  33. stripBanners: true
  34. },
  35. dist: {
  36. src: ['js/validator.js'],
  37. dest: 'dist/validator.js'
  38. }
  39. },
  40. copy: {
  41. docs: {
  42. expand: true,
  43. cwd: './dist',
  44. src: '*',
  45. dest: 'docs/dist'
  46. }
  47. },
  48. uglify: {
  49. options: {
  50. banner: '<%= banner %>',
  51. report: 'min'
  52. },
  53. min: {
  54. src: ['js/validator.js'],
  55. dest: 'dist/validator.min.js'
  56. }
  57. },
  58. qunit: {
  59. options: {
  60. inject: 'js/tests/unit/phantom.js'
  61. },
  62. files: ['js/tests/*.html']
  63. },
  64. watch: {
  65. src: {
  66. files: '<%= jshint.src.src %>',
  67. tasks: ['jshint:src', 'qunit']
  68. },
  69. test: {
  70. files: '<%= jshint.test.src %>',
  71. tasks: ['jshint:test', 'qunit']
  72. }
  73. },
  74. jekyll: {
  75. docs: {}
  76. },
  77. validation: {
  78. options: {
  79. reset: true,
  80. relaxerror: [
  81. "Bad value X-UA-Compatible for attribute http-equiv on element meta.",
  82. "Element img is missing required attribute src."
  83. ]
  84. },
  85. files: {
  86. src: ["_gh_pages/**/*.html"]
  87. }
  88. }
  89. });
  90. // These plugins provide necessary tasks.
  91. grunt.loadNpmTasks('grunt-contrib-concat');
  92. grunt.loadNpmTasks('grunt-contrib-copy');
  93. grunt.loadNpmTasks('grunt-contrib-jshint');
  94. grunt.loadNpmTasks('grunt-contrib-qunit');
  95. grunt.loadNpmTasks('grunt-contrib-uglify');
  96. grunt.loadNpmTasks('grunt-contrib-watch');
  97. grunt.loadNpmTasks('grunt-jekyll');
  98. grunt.loadNpmTasks('grunt-html-validation');
  99. grunt.loadNpmTasks('grunt-sed');
  100. // Docs HTML validation task
  101. grunt.registerTask('validate-html', ['jekyll', 'validation']);
  102. // Test task.
  103. grunt.registerTask('test', ['jshint', 'qunit']);
  104. // Docs distribution task.
  105. grunt.registerTask('dist-docs', 'copy:docs');
  106. // Distribution task.
  107. grunt.registerTask('dist', ['concat', 'uglify', 'dist-docs']);
  108. // Default task.
  109. grunt.registerTask('default', ['test', 'dist']);
  110. // Version numbering task.
  111. // grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
  112. // This can be overzealous, so its changes should always be manually reviewed!
  113. grunt.registerTask('change-version-number', ['sed']);
  114. };