rollup.config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import nodeResolve from '@rollup/plugin-node-resolve'
  2. import commonjs from "@rollup/plugin-commonjs"
  3. import babel from '@rollup/plugin-babel'
  4. import json from '@rollup/plugin-json'
  5. import ts from "rollup-plugin-typescript2"
  6. const extensions = [".js", ".ts"]
  7. const plugins = [
  8. json(),
  9. ts(),
  10. nodeResolve({
  11. preferBuiltins: true,
  12. mainFields: ['browser']
  13. }),
  14. commonjs(),
  15. // (uglify()),
  16. // (process.env === 'production' && uglify()),
  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. export default [{
  35. input: "./src/worker/compdfkit_worker.js",
  36. output: [
  37. {
  38. format: "es",
  39. file: "../example/lib/pdfviewer.worker.js",
  40. sourceMap: true
  41. }
  42. ],
  43. plugins
  44. },
  45. {
  46. input: "./src/Document.ts",
  47. output: [
  48. {
  49. format: "es",
  50. file: "../example/lib/webview.min.js",
  51. sourceMap: true
  52. }
  53. ],
  54. plugins
  55. }];