rollup-es5.config.dev.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. import { babel } from "@rollup/plugin-babel";
  2. import resolve from "@rollup/plugin-node-resolve";
  3. import commonjs from "@rollup/plugin-commonjs";
  4. import replace from "@rollup/plugin-replace";
  5. import fs from "fs";
  6. const babelPresets = [
  7. [
  8. "@babel/preset-env",
  9. {
  10. corejs: 3,
  11. modules: false,
  12. useBuiltIns: "usage",
  13. targets: {
  14. ie: "11",
  15. safari: "10"
  16. }
  17. }
  18. ]
  19. ];
  20. const bundledPlugins = [
  21. commonjs(),
  22. resolve(),
  23. babel({
  24. babelHelpers: "bundled",
  25. babelrc: false,
  26. exclude: "node_modules/**",
  27. presets: babelPresets,
  28. compact: false,
  29. plugins: [["babel-plugin-transform-async-to-promises", { externalHelpers: true }]]
  30. })
  31. ];
  32. const inlinePlugins = [
  33. commonjs(),
  34. resolve(),
  35. babel({
  36. babelHelpers: "inline",
  37. babelrc: false,
  38. exclude: "node_modules/**",
  39. presets: babelPresets,
  40. compact: false
  41. })
  42. ];
  43. export default [{
  44. input: "lib/z-worker.js",
  45. output: [{
  46. file: "lib/z-worker-inline.js",
  47. format: "umd"
  48. }],
  49. plugins: inlinePlugins
  50. }, {
  51. input: "lib/z-worker-inline-template-base64.js",
  52. output: [{
  53. file: "lib/z-worker-inline.js",
  54. format: "es"
  55. }],
  56. plugins: [replace({
  57. preventAssignment: true,
  58. "__workerCode__": () => JSON.stringify(fs.readFileSync("lib/z-worker-inline.js", { encoding: "base64" }))
  59. })]
  60. }, {
  61. input: ["lib/zip.js"],
  62. output: [{
  63. file: "dist/zip-es5.min.js",
  64. format: "umd",
  65. name: "zip"
  66. }, {
  67. file: "dist/zip-es5.js",
  68. format: "umd",
  69. name: "zip"
  70. }],
  71. plugins: bundledPlugins
  72. }, {
  73. input: ["lib/zip-full.js"],
  74. output: [{
  75. file: "dist/zip-full-es5.min.js",
  76. format: "umd",
  77. name: "zip"
  78. }, {
  79. file: "dist/zip-full-es5.js",
  80. format: "umd",
  81. name: "zip"
  82. }],
  83. plugins: bundledPlugins
  84. }, {
  85. input: "lib/zip-no-worker.js",
  86. output: [{
  87. file: "dist/zip-no-worker-es5.min.js",
  88. format: "umd",
  89. name: "zip"
  90. }],
  91. plugins: bundledPlugins
  92. }, {
  93. input: "lib/zip-no-worker-deflate.js",
  94. output: [{
  95. file: "dist/zip-no-worker-deflate-es5.min.js",
  96. format: "umd",
  97. name: "zip"
  98. }],
  99. plugins: bundledPlugins
  100. }, {
  101. input: "lib/zip-no-worker-inflate.js",
  102. output: [{
  103. file: "dist/zip-no-worker-inflate-es5.min.js",
  104. format: "umd",
  105. name: "zip"
  106. }],
  107. plugins: bundledPlugins
  108. }, {
  109. input: "lib/zip-fs.js",
  110. output: [{
  111. file: "dist/zip-fs-es5.min.js",
  112. format: "umd",
  113. name: "zip"
  114. }, {
  115. file: "dist/zip-fs-es5.js",
  116. format: "umd",
  117. name: "zip"
  118. }],
  119. plugins: bundledPlugins
  120. }, {
  121. input: "index.js",
  122. output: [{
  123. file: "dist/zip-fs-full-es5.min.js",
  124. format: "umd",
  125. name: "zip"
  126. }, {
  127. file: "dist/zip-fs-full-es5.js",
  128. format: "umd",
  129. name: "zip"
  130. }],
  131. plugins: bundledPlugins
  132. }, {
  133. input: "lib/z-worker-bootstrap-pako.js",
  134. output: [{
  135. file: "dist/z-worker-pako-es5.js",
  136. format: "iife"
  137. }],
  138. plugins: inlinePlugins
  139. }, {
  140. input: "lib/z-worker-bootstrap-fflate.js",
  141. output: [{
  142. file: "dist/z-worker-fflate-es5.js",
  143. format: "iife"
  144. }],
  145. plugins: inlinePlugins
  146. }, {
  147. input: "lib/z-worker.js",
  148. output: [{
  149. file: "dist/z-worker-es5.js",
  150. format: "iife"
  151. }],
  152. plugins: inlinePlugins
  153. }];