Gruntfile.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. module.exports = function(grunt) {
  2. grunt.initConfig({
  3. pkg: grunt.file.readJSON('package.json'),
  4. buildDir: 'dist',
  5. banner: [
  6. '/**',
  7. ' * BootstrapValidator v<%= pkg.version %> (<%= pkg.homepage %>)',
  8. ' *',
  9. ' * A jQuery plugin to validate form fields. Use with Bootstrap 3',
  10. ' *',
  11. ' * @author Nguyen Huu Phuoc <phuoc@huuphuoc.me>',
  12. ' * @copyright (c) 2013 Nguyen Huu Phuoc',
  13. ' * @license MIT',
  14. ' */\n\n'
  15. ].join('\n'),
  16. copy: {
  17. main: {
  18. files: [
  19. { cwd: 'src/css', src: '**', dest: '<%= buildDir %>/css', expand: true, flatten: true, filter: 'isFile' }
  20. ]
  21. }
  22. },
  23. cssmin: {
  24. minify: { expand: true, cwd: 'src/css/', src: ['*.css'], dest: '<%= buildDir %>/css/', ext: '.min.css' },
  25. add_banner: {
  26. options: {
  27. banner: '<%= banner %>'
  28. },
  29. files: {
  30. '<%= buildDir %>/css/bootstrapValidator.min.css': ['src/css/bootstrapValidator.css']
  31. }
  32. }
  33. },
  34. concat: {
  35. options: {
  36. separator: ';',
  37. stripBanners: true,
  38. banner: '<%= banner %>'
  39. },
  40. dist: {
  41. src: ['src/js/bootstrapValidator.js', 'src/js/validator/*.js'],
  42. dest: '<%= buildDir %>/js/bootstrapValidator.js'
  43. }
  44. },
  45. uglify: {
  46. options: {
  47. banner: '<%= banner %>'
  48. },
  49. build: {
  50. src: ['<%= buildDir %>/js/bootstrapValidator.js'],
  51. dest: '<%= buildDir %>/js/bootstrapValidator.min.js'
  52. }
  53. },
  54. watch: {
  55. scripts: {
  56. files: ['src/css/**', 'src/js/**'],
  57. tasks: ['build'],
  58. options: {
  59. spawn: false
  60. }
  61. }
  62. }
  63. });
  64. grunt.registerTask('default', 'build');
  65. grunt.registerTask('build', ['copy', 'cssmin', 'concat', 'uglify']);
  66. grunt.loadNpmTasks('grunt-contrib-concat');
  67. grunt.loadNpmTasks('grunt-contrib-copy');
  68. grunt.loadNpmTasks('grunt-contrib-cssmin');
  69. grunt.loadNpmTasks('grunt-contrib-uglify');
  70. grunt.loadNpmTasks('grunt-contrib-watch');
  71. };