Gruntfile.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. ' * A jQuery plugin to validate form fields. Use with Bootstrap 3',
  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. ]
  22. }
  23. },
  24. cssmin: {
  25. minify: { expand: true, cwd: 'src/css/', src: ['*.css'], dest: '<%= buildDir %>/css/', ext: '.min.css' },
  26. add_banner: {
  27. options: {
  28. banner: '<%= banner %>'
  29. },
  30. files: {
  31. '<%= buildDir %>/css/bootstrapValidator.min.css': ['src/css/bootstrapValidator.css']
  32. }
  33. }
  34. },
  35. concat: {
  36. options: {
  37. separator: ';',
  38. stripBanners: true,
  39. banner: '<%= banner %>'
  40. },
  41. dist: {
  42. src: ['src/js/bootstrapValidator.js', 'src/js/validator/*.js'],
  43. dest: '<%= buildDir %>/js/bootstrapValidator.js'
  44. }
  45. },
  46. uglify: {
  47. options: {
  48. banner: '<%= banner %>'
  49. },
  50. build: {
  51. src: ['<%= buildDir %>/js/bootstrapValidator.js'],
  52. dest: '<%= buildDir %>/js/bootstrapValidator.min.js'
  53. }
  54. },
  55. watch: {
  56. scripts: {
  57. files: ['src/css/**', 'src/js/**'],
  58. tasks: ['build'],
  59. options: {
  60. spawn: false
  61. }
  62. }
  63. }
  64. });
  65. grunt.registerTask('default', 'build');
  66. grunt.registerTask('build', ['copy', 'cssmin', 'concat', 'uglify']);
  67. grunt.loadNpmTasks('grunt-contrib-concat');
  68. grunt.loadNpmTasks('grunt-contrib-copy');
  69. grunt.loadNpmTasks('grunt-contrib-cssmin');
  70. grunt.loadNpmTasks('grunt-contrib-uglify');
  71. grunt.loadNpmTasks('grunt-contrib-watch');
  72. };