rollup.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import nodeResolve from '@rollup/plugin-node-resolve'
  2. import commonjs from "@rollup/plugin-commonjs"
  3. import babel from '@rollup/plugin-babel'
  4. import terser from '@rollup/plugin-terser';
  5. import json from '@rollup/plugin-json'
  6. import ts from "rollup-plugin-typescript2"
  7. const extensions = [".js", ".ts"]
  8. const reserved = ['ComPDFKitJS', 'DataArray', 'LineType', 'PageSize', 'Rect', 'RGBColor', 'FontDa', 'PDFDestination', 'WidgetItem', 'WidgetItemsArray', 'TextFindItem', 'EditCharPlace', 'EndEditCharPlace', 'RectArray', 'CursorPoints', 'EditTextStyle', 'U8StringData', 'PDFRange', 'TextRectArray']
  9. const plugins = [
  10. json(),
  11. ts(),
  12. terser({
  13. mangle: {
  14. reserved
  15. }
  16. }),
  17. nodeResolve({
  18. preferBuiltins: true,
  19. mainFields: ['browser']
  20. }),
  21. commonjs(),
  22. babel({
  23. extensions,
  24. exclude: 'node_modules/**', // 防止打包node_modules下的文件
  25. // 使用预设
  26. presets: [['@babel/preset-env', {
  27. "modules": false,
  28. // 目标浏览器
  29. "targets": {
  30. "edge": '17',
  31. "firefox": '60',
  32. "chrome": '67',
  33. "safari": '10.0',
  34. 'ie': '10',
  35. },
  36. }]]
  37. })
  38. ]
  39. export default [{
  40. input: "./src/worker/compdfkit_worker.js",
  41. output: [
  42. {
  43. format: "es",
  44. file: "../webview/lib/PDFWorker.js"
  45. }
  46. ],
  47. plugins
  48. },
  49. {
  50. input: "./src/index.js",
  51. output: [
  52. {
  53. format: "es",
  54. file: "../webview/lib/webview.min.js"
  55. }
  56. ],
  57. plugins
  58. }];