rollup.config.js 1.1 KB

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