Gruntfile.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. module.exports = function(grunt) {
  2. grunt.initConfig({
  3. pkg: grunt.file.readJSON('package.json'),
  4. buildDir: 'dist',
  5. banner: [
  6. '/**',
  7. ' * BootstrapValidator (<%= pkg.homepage %>)',
  8. ' *',
  9. ' * <%= pkg.description %>',
  10. ' *',
  11. ' * @version v<%= pkg.version %>',
  12. ' * @author <%= pkg.author.url %>',
  13. ' * @copyright (c) 2013 - 2014 Nguyen Huu Phuoc',
  14. ' * @license MIT',
  15. ' */\n\n'
  16. ].join('\n'),
  17. copy: {
  18. main: {
  19. files: [
  20. { cwd: 'src/css', src: '**', dest: '<%= buildDir %>/css', expand: true, flatten: true, filter: 'isFile' },
  21. { cwd: 'src/js/languages', src: '**', dest: '<%= buildDir %>/js/languages', expand: true, flatten: true, filter: 'isFile' }
  22. ]
  23. }
  24. },
  25. cssmin: {
  26. minify: { expand: true, cwd: 'src/css/', src: ['*.css'], dest: '<%= buildDir %>/css/', ext: '.min.css' },
  27. add_banner: {
  28. options: {
  29. banner: '<%= banner %>'
  30. },
  31. files: {
  32. '<%= buildDir %>/css/bootstrapValidator.min.css': ['src/css/bootstrapValidator.css']
  33. }
  34. }
  35. },
  36. concat: {
  37. options: {
  38. separator: ';',
  39. stripBanners: true,
  40. banner: '<%= banner %>'
  41. },
  42. dist: {
  43. src: ['src/js/bootstrapValidator.js', 'src/js/validator/*.js'],
  44. dest: '<%= buildDir %>/js/bootstrapValidator.js'
  45. }
  46. },
  47. uglify: {
  48. options: {
  49. banner: '<%= banner %>'
  50. },
  51. build: {
  52. src: ['<%= buildDir %>/js/bootstrapValidator.js'],
  53. dest: '<%= buildDir %>/js/bootstrapValidator.min.js'
  54. }
  55. },
  56. jshint: {
  57. all: [
  58. 'src/js/**/*.js'
  59. ],
  60. options: {
  61. browser: true,
  62. camelcase: true,
  63. curly: true,
  64. eqeqeq: true,
  65. eqnull: true,
  66. es3: true,
  67. expr: true,
  68. laxbreak: true, // Allow line breaking before && or ||
  69. loopfunc: true,
  70. newcap: true,
  71. noarg: true,
  72. onevar: true,
  73. sub: true,
  74. undef: true,
  75. white: true
  76. /*
  77. 'node': false,
  78. 'boss': false,
  79. 'debug': false,
  80. 'devel': false,
  81. 'evil': false,
  82. 'forin': false,
  83. 'immed': false,
  84. 'noempty': false,
  85. 'nonew': false,
  86. 'plusplus': false,
  87. 'regexp': false,
  88. 'strict': false,
  89. 'globals': {
  90. 'define': false
  91. }
  92. */
  93. }
  94. },
  95. watch: {
  96. scripts: {
  97. files: ['src/css/**', 'src/js/**'],
  98. tasks: ['build'],
  99. options: {
  100. spawn: false
  101. }
  102. }
  103. }
  104. });
  105. grunt.registerTask('default', 'build');
  106. grunt.registerTask('build', ['copy', 'cssmin', 'concat', 'uglify']);
  107. grunt.loadNpmTasks('grunt-contrib-concat');
  108. grunt.loadNpmTasks('grunt-contrib-copy');
  109. grunt.loadNpmTasks('grunt-contrib-cssmin');
  110. grunt.loadNpmTasks('grunt-contrib-jshint');
  111. grunt.loadNpmTasks('grunt-contrib-uglify');
  112. grunt.loadNpmTasks('grunt-contrib-watch');
  113. };