Gruntfile.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. "use strict";
  2. module.exports = function(grunt) {
  3. // Project configuration.
  4. grunt.initConfig({
  5. // Metadata.
  6. pkg: grunt.file.readJSON("idle-timer.jquery.json"),
  7. banner: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
  8. "<%= grunt.template.today('yyyy-mm-dd') %>\n" +
  9. "<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
  10. "* Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
  11. " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n",
  12. minbanner: "/*! <%= pkg.title || pkg.name %> v<%= pkg.version %> <%= grunt.template.today('yyyy-mm-dd') %> | " +
  13. "<%= pkg.homepage ? pkg.homepage : '' %> | (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %> | " +
  14. "Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n",
  15. // Task configuration.
  16. concat: {
  17. options: {
  18. banner: "<%= banner %>",
  19. stripBanners: true
  20. },
  21. dist: {
  22. files: [
  23. {
  24. src: ["src/<%= pkg.name %>.js"],
  25. dest: "dist/<%= pkg.name %>.js"
  26. },
  27. {
  28. src: ["src/<%= pkg.name %>.js"],
  29. dest: "dist/<%= pkg.name %>.<%= pkg.version %>.js"
  30. }
  31. ]
  32. },
  33. },
  34. uglify: {
  35. options: {
  36. banner: "<%= minbanner %>"
  37. },
  38. dist: {
  39. files: [
  40. {
  41. src: "<%= concat.dist.files[0].dest %>",
  42. dest: "dist/<%= pkg.name %>.min.js"
  43. },
  44. {
  45. src: "<%= concat.dist.files[0].dest %>",
  46. dest: "dist/<%= pkg.name %>.<%= pkg.version %>.min.js"
  47. }
  48. ]
  49. },
  50. },
  51. qunit: {
  52. options: {
  53. timeout: 30000,
  54. "--web-security": "no",
  55. coverage: {
  56. src: [ "src/<%= pkg.name %>.js" ],
  57. instrumentedFiles: "temp/",
  58. htmlReport: "build/report/coverage",
  59. lcovReport: "build/report/lcov",
  60. linesThresholdPct: 0
  61. }
  62. },
  63. files: ["test/**/*.html"]
  64. },
  65. coveralls: {
  66. options: {
  67. // dont fail if coveralls fails
  68. force: true
  69. },
  70. main_target: {
  71. src: "build/report/lcov/lcov.info"
  72. }
  73. },
  74. jshint: {
  75. gruntfile: {
  76. options: {
  77. jshintrc: ".jshintrc"
  78. },
  79. src: "Gruntfile.js"
  80. },
  81. src: {
  82. options: {
  83. jshintrc: "src/.jshintrc"
  84. },
  85. src: ["src/**/*.js"]
  86. },
  87. test: {
  88. options: {
  89. jshintrc: "test/.jshintrc"
  90. },
  91. src: ["test/**/*.js"]
  92. },
  93. },
  94. watch: {
  95. gruntfile: {
  96. files: "<%= jshint.gruntfile.src %>",
  97. tasks: ["jshint:gruntfile"]
  98. },
  99. src: {
  100. files: "<%= jshint.src.src %>",
  101. tasks: ["jshint:src", "qunit"]
  102. },
  103. test: {
  104. files: "<%= jshint.test.src %>",
  105. tasks: ["jshint:test", "qunit"]
  106. },
  107. },
  108. });
  109. // These plugins provide necessary tasks.
  110. grunt.loadNpmTasks("grunt-contrib-jshint");
  111. grunt.loadNpmTasks("grunt-coveralls");
  112. grunt.loadNpmTasks("grunt-qunit-istanbul");
  113. grunt.loadNpmTasks("grunt-contrib-concat");
  114. grunt.loadNpmTasks("grunt-contrib-uglify");
  115. grunt.loadNpmTasks("grunt-contrib-watch");
  116. // Default task.
  117. grunt.registerTask("default", ["jshint", "qunit", "concat", "uglify"]);
  118. };