Gruntfile.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. 'use strict';
  2. module.exports = function(grunt) {
  3. // Project configuration.
  4. grunt.initConfig({
  5. // Metadata.
  6. pkg: grunt.file.readJSON('bootstrap-table.jquery.json'),
  7. banner: '/*\n' +
  8. '* <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
  9. '<%= pkg.homepage ? "* " + pkg.homepage : "" %>\n' +
  10. '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>\n' +
  11. '* Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n' +
  12. '*/\n',
  13. // Task configuration.
  14. clean: ['dist', 'docs/dist'],
  15. concat: {
  16. basic_target: {
  17. src: ['src/<%= pkg.name %>.js', 'src/extensions/**/*.js'],
  18. dest: 'dist/<%= pkg.name %>-all.js'
  19. },
  20. locale_target: {
  21. src: ['src/locale/**/*.js'],
  22. dest: 'dist/<%= pkg.name %>-locale-all.js'
  23. }
  24. },
  25. uglify: {
  26. options: {
  27. banner: '<%= banner %>'
  28. },
  29. basic_target: {
  30. files: {
  31. 'dist/<%= pkg.name %>.min.js': ['src/<%=pkg.name %>.js'],
  32. 'dist/<%= pkg.name %>-all.min.js': ['dist/<%=pkg.name %>-all.js'],
  33. 'dist/<%= pkg.name %>-locale-all.min.js': ['dist/<%=pkg.name %>-locale-all.js']
  34. }
  35. },
  36. locale_target: {
  37. files: [{
  38. expand: true,
  39. cwd: 'src/locale',
  40. src: '**/*.js',
  41. dest: 'dist/locale',
  42. ext: '.min.js' // replace .js to .min.js
  43. }]
  44. },
  45. extensions_target: {
  46. files: [{
  47. expand: true,
  48. cwd: 'src/extensions',
  49. src: '**/*.js',
  50. dest: 'dist/extensions',
  51. ext: '.min.js' // replace .js to .min.js
  52. }]
  53. }
  54. },
  55. cssmin: {
  56. add_banner: {
  57. options: {
  58. banner: '<%= banner %>'
  59. },
  60. files: {
  61. 'dist/<%= pkg.name %>.min.css': ['src/<%=pkg.name %>.css']
  62. }
  63. }
  64. },
  65. copy: {
  66. source: {
  67. cwd: 'src', // set working folder / root to copy
  68. src: ['**/*.js', '**/*.css'], // copy all files and subfolders
  69. dest: 'dist', // destination folder
  70. expand: true // required when using cwd
  71. },
  72. files: {
  73. cwd: 'dist', // set working folder / root to copy
  74. src: '**/*', // copy all files and subfolders
  75. dest: 'docs/dist', // destination folder
  76. expand: true // required when using cwd
  77. }
  78. }
  79. });
  80. grunt.loadNpmTasks('grunt-contrib-clean');
  81. grunt.loadNpmTasks('grunt-contrib-concat');
  82. grunt.loadNpmTasks('grunt-contrib-uglify');
  83. grunt.loadNpmTasks('grunt-contrib-cssmin');
  84. grunt.loadNpmTasks('grunt-contrib-copy');
  85. grunt.registerTask('default', ['clean', 'concat', 'uglify', 'cssmin', 'copy']);
  86. };