rollup.webviewer.config.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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', 'TextFindItemArray', 'EditCharPlace', 'EndEditCharPlace', 'RectArray', 'CursorPoints', 'EditTextStyle', 'U8StringData', 'PDFRange', 'TextRectArray']
  9. const plugins = [
  10. json(),
  11. ts(),
  12. nodeResolve({
  13. preferBuiltins: true,
  14. mainFields: ['browser']
  15. }),
  16. commonjs(),
  17. babel({
  18. extensions,
  19. exclude: 'node_modules/**', // 防止打包node_modules下的文件
  20. // 使用预设
  21. presets: [['@babel/preset-env', {
  22. "modules": false,
  23. // 目标浏览器
  24. "targets": {
  25. "edge": '17',
  26. "firefox": '60',
  27. "chrome": '67',
  28. "safari": '10.0',
  29. 'ie': '10',
  30. },
  31. }]]
  32. })
  33. ]
  34. plugins.push(
  35. terser({
  36. mangle: {
  37. reserved
  38. }
  39. }))
  40. export default [{
  41. input: "./webviewer.js",
  42. output: [
  43. {
  44. format: "es",
  45. file: "../webview/lib/webviewer.js"
  46. },
  47. {
  48. format: "umd",
  49. name: 'ComPDFKitViewer',
  50. file: "../webview/lib/webviewer.global.js",
  51. sourcemap: false
  52. }
  53. ],
  54. plugins
  55. }];