gruntfile.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. module.exports = function (grunt) {
  2. var bannerTemplate = '' +
  3. '// <%= pkg.name %> version <%= pkg.version %>\n' +
  4. '// <%= pkg.repository.url %>\n' +
  5. '// (<%= pkg.license %>) <%= grunt.template.today("dd-mm-yyyy") %>\n' +
  6. '// <%= pkg.author %>\n';
  7. grunt.initConfig({
  8. pkg: grunt.file.readJSON('package.json'),
  9. preprocess : {
  10. options: {
  11. context : {
  12. DEBUG: true
  13. }
  14. },
  15. test : {
  16. src : 'test/index.pre.html',
  17. dest : 'test/index.html'
  18. },
  19. index: {
  20. src: 'index.pre.html',
  21. dest: 'index.html'
  22. }
  23. },
  24. concat: {
  25. options: {
  26. separator: '\n',
  27. banner: bannerTemplate
  28. },
  29. dist: {
  30. src: [
  31. 'src/intro.js',
  32. 'src/lib.js',
  33. 'src/jquery.input.js',
  34. 'src/repeater.js',
  35. 'src/outro.js'
  36. ],
  37. dest: '<%= pkg.name %>.js'
  38. }
  39. },
  40. uglify: {
  41. options: { banner: bannerTemplate },
  42. dist: {
  43. files: { '<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>'] }
  44. }
  45. },
  46. qunit: {
  47. // http://stackoverflow.com/questions/22409002/qunitphantomjs-ajax-success-handler-not-called-in-grunt-using-qunit-with-phant
  48. options : {
  49. '--web-security': false,
  50. '--local-to-remote-url-access': true
  51. },
  52. all: ['test/index.html']
  53. },
  54. watch: {
  55. scripts: {
  56. files: ['**/*'],
  57. tasks: ['preprocess', 'concat', 'uglify', 'qunit'],
  58. options: { spawn: true }
  59. }
  60. }
  61. });
  62. grunt.loadNpmTasks('grunt-preprocess');
  63. grunt.loadNpmTasks('grunt-contrib-concat');
  64. grunt.loadNpmTasks('grunt-contrib-uglify');
  65. grunt.loadNpmTasks('grunt-contrib-watch');
  66. grunt.loadNpmTasks('grunt-contrib-qunit');
  67. grunt.registerTask('default', ['preprocess', 'concat', 'uglify', 'qunit']);
  68. grunt.registerTask('test', ['preprocess', 'concat', 'uglify', 'qunit']);
  69. };