Gruntfile.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. watch: {
  57. scripts: {
  58. files: ['src/css/**', 'src/js/**'],
  59. tasks: ['build'],
  60. options: {
  61. spawn: false
  62. }
  63. }
  64. }
  65. });
  66. grunt.registerTask('default', 'build');
  67. grunt.registerTask('build', ['copy', 'cssmin', 'concat', 'uglify']);
  68. grunt.loadNpmTasks('grunt-contrib-concat');
  69. grunt.loadNpmTasks('grunt-contrib-copy');
  70. grunt.loadNpmTasks('grunt-contrib-cssmin');
  71. grunt.loadNpmTasks('grunt-contrib-uglify');
  72. grunt.loadNpmTasks('grunt-contrib-watch');
  73. };