Gruntfile.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*jshint node: true */
  2. module.exports = function(grunt) {
  3. var browsers = [{
  4. browserName: "iphone",
  5. platform: "OS X 10.8",
  6. version: "6"
  7. }, {
  8. browserName: "iphone",
  9. platform: "OS X 10.10",
  10. version: "9.2"
  11. }, {
  12. browserName: "android",
  13. platform: "Linux",
  14. version: "4.0"
  15. }, {
  16. browserName: "android",
  17. platform: "Linux",
  18. version: "4.4"
  19. }, {
  20. browserName: "android",
  21. platform: "Linux",
  22. version: "5.1"
  23. }, {
  24. browserName: "firefox",
  25. platform: "Windows 10"
  26. }, {
  27. browserName: "chrome",
  28. platform: "Windows 10"
  29. }, {
  30. browserName: "internet explorer",
  31. platform: "XP",
  32. version: "7"
  33. }, {
  34. browserName: "internet explorer",
  35. platform: "Windows 7",
  36. version: "8"
  37. }, {
  38. browserName: "internet explorer",
  39. platform: "Windows 7",
  40. version: "9"
  41. }, {
  42. browserName: "internet explorer",
  43. platform: "Windows 8",
  44. version: "10"
  45. }, {
  46. browserName: "internet explorer",
  47. platform: "Windows 10",
  48. version: "11"
  49. }, {
  50. browserName: "microsoftedge",
  51. platform: "Windows 10",
  52. version: "13.10586"
  53. }, {
  54. browserName: "opera",
  55. platform: "Windows 2008",
  56. version: "12"
  57. }, {
  58. browserName: "safari",
  59. platform: "OS X 10.8",
  60. version: "6"
  61. }, {
  62. browserName: "safari",
  63. platform: "OS X 10.9",
  64. version: "7"
  65. }, {
  66. browserName: "safari",
  67. platform: "OS X 10.10",
  68. version: "8"
  69. }, {
  70. browserName: "safari",
  71. platform: "OS X 10.11",
  72. version: "9"
  73. }];
  74. var tags = [];
  75. if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST != "false") {
  76. tags.push("pr" + process.env.TRAVIS_PULL_REQUEST);
  77. } else if (process.env.TRAVIS_BRANCH) {
  78. tags.push(process.env.TRAVIS_BRANCH);
  79. }
  80. grunt.initConfig({
  81. connect: {
  82. server: {
  83. options: {
  84. base: "",
  85. port: 9999
  86. }
  87. }
  88. },
  89. 'saucelabs-qunit': {
  90. all: {
  91. options: {
  92. urls: ["http://127.0.0.1:9999/test/index.html"],
  93. tunnelTimeout: 5,
  94. build: process.env.TRAVIS_JOB_ID,
  95. concurrency: 3,
  96. browsers: browsers,
  97. testname: "qunit tests",
  98. tags: tags
  99. }
  100. }
  101. },
  102. jshint: {
  103. options: {
  104. jshintrc: "./.jshintrc"
  105. },
  106. all: ['./lib/*.js']
  107. },
  108. browserify: {
  109. all: {
  110. files: {
  111. 'dist/jszip.js': ['lib/index.js']
  112. },
  113. options: {
  114. browserifyOptions: {
  115. standalone: 'JSZip',
  116. insertGlobalVars : {
  117. Buffer: function () {
  118. // instead of the full polyfill, we just use the raw value
  119. // (or undefined).
  120. return '(typeof Buffer !== "undefined" ? Buffer : undefined)';
  121. }
  122. }
  123. },
  124. postBundleCB: function(err, src, done) {
  125. // add the license
  126. var license = require('fs').readFileSync('lib/license_header.js');
  127. // remove the source mapping of zlib.js, see #75
  128. var srcWithoutSourceMapping = src.toString().replace(/\/\/@ sourceMappingURL=raw..flate.min.js.map/g, '');
  129. done(err, license + srcWithoutSourceMapping);
  130. }
  131. }
  132. }
  133. },
  134. uglify: {
  135. options: {
  136. report: 'gzip',
  137. mangle: true,
  138. preserveComments: 'some'
  139. },
  140. all: {
  141. src: 'dist/jszip.js',
  142. dest: 'dist/jszip.min.js'
  143. }
  144. }
  145. });
  146. grunt.loadNpmTasks("grunt-saucelabs");
  147. grunt.loadNpmTasks("grunt-contrib-connect");
  148. grunt.loadNpmTasks('grunt-browserify');
  149. grunt.loadNpmTasks('grunt-contrib-jshint');
  150. grunt.loadNpmTasks('grunt-contrib-uglify');
  151. if (process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
  152. grunt.registerTask("test", ["connect", "saucelabs-qunit"]);
  153. } else {
  154. grunt.registerTask("test", []);
  155. }
  156. grunt.registerTask("build", ["browserify", "uglify"]);
  157. grunt.registerTask("default", ["jshint", "build"]);
  158. };