rollup.config.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import nodeResolve from '@rollup/plugin-node-resolve'
  2. import commonjs from "@rollup/plugin-commonjs"
  3. import babel from '@rollup/plugin-babel'
  4. import { uglify } from 'rollup-plugin-uglify'
  5. import json from '@rollup/plugin-json';
  6. import ts from "rollup-plugin-typescript2"
  7. const extensions = [".js", ".ts"]
  8. const plugins = [
  9. json(),
  10. ts(),
  11. nodeResolve({
  12. preferBuiltins: true,
  13. mainFields: ['browser']
  14. }),
  15. commonjs(),
  16. // (uglify()),
  17. // (process.env === 'production' && uglify()),
  18. babel({
  19. extensions,
  20. exclude: 'node_modules/**', // 防止打包node_modules下的文件
  21. // 使用预设
  22. presets: [['@babel/preset-env', {
  23. "modules": false,
  24. // 目标浏览器
  25. "targets": {
  26. "edge": '17',
  27. "firefox": '60',
  28. "chrome": '67',
  29. "safari": '10.0',
  30. 'ie': '10',
  31. },
  32. }]]
  33. })
  34. ]
  35. export default [{
  36. input: "./src/worker/compdfkit.worker.js",
  37. output: [
  38. {
  39. format: "es",
  40. file: "../webviewer/lib/pdfviewer.worker.js",
  41. sourceMap: true
  42. }
  43. ],
  44. plugins
  45. },
  46. {
  47. input: "./src/index.ts",
  48. output: [
  49. {
  50. format: "es",
  51. file: "../webviewer/lib/webview.min.js",
  52. sourceMap: true
  53. }
  54. ],
  55. plugins
  56. }];