rollup.config.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. // rollup.config.js
  5. import { terser } from 'rollup-plugin-terser'
  6. import resolve from '@rollup/plugin-node-resolve'
  7. import commonjs from '@rollup/plugin-commonjs'
  8. import sucrase from '@rollup/plugin-sucrase'
  9. import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel'
  10. import typescript from '@rollup/plugin-typescript'
  11. import pkg from './package.json'
  12. export default [
  13. {
  14. input: {
  15. app: './src/app.ts',
  16. fs: './src/fs.ts',
  17. path: './src/path.ts',
  18. dialog: './src/dialog.ts',
  19. event: './src/event.ts',
  20. updater: './src/updater.ts',
  21. http: './src/http.ts',
  22. index: './src/index.ts',
  23. shell: './src/shell.ts',
  24. tauri: './src/tauri.ts',
  25. window: './src/window.ts',
  26. cli: './src/cli.ts',
  27. notification: './src/notification.ts',
  28. globalShortcut: './src/globalShortcut.ts',
  29. process: './src/process.ts',
  30. clipboard: './src/clipboard.ts'
  31. },
  32. treeshake: true,
  33. perf: true,
  34. output: [
  35. {
  36. dir: 'dist/',
  37. entryFileNames: '[name].cjs',
  38. format: 'cjs',
  39. chunkFileNames: '[name]-[hash].cjs',
  40. exports: 'named',
  41. globals: {}
  42. },
  43. {
  44. dir: 'dist/',
  45. entryFileNames: '[name].js',
  46. format: 'esm',
  47. exports: 'named',
  48. globals: {}
  49. }
  50. ],
  51. plugins: [
  52. commonjs({}),
  53. resolve({
  54. // pass custom options to the resolve plugin
  55. customResolveOptions: {
  56. moduleDirectories: ['node_modules']
  57. }
  58. }),
  59. typescript({
  60. tsconfig: './tsconfig.json'
  61. }),
  62. babel({
  63. configFile: false,
  64. presets: [['@babel/preset-env'], ['@babel/preset-typescript']]
  65. }),
  66. terser()
  67. ],
  68. external: [
  69. ...Object.keys(pkg.dependencies || {}),
  70. ...Object.keys(pkg.peerDependencies || {})
  71. ]
  72. },
  73. {
  74. input: {
  75. bundle: './src/bundle.ts'
  76. },
  77. output: [
  78. {
  79. name: '__TAURI__',
  80. dir: '../../core/tauri/scripts',
  81. entryFileNames: 'bundle.js',
  82. format: 'umd',
  83. plugins: [
  84. getBabelOutputPlugin({
  85. presets: [['@babel/preset-env', { modules: 'umd' }]],
  86. allowAllFormats: true
  87. }),
  88. terser()
  89. ],
  90. globals: {}
  91. }
  92. ],
  93. plugins: [
  94. sucrase({
  95. exclude: ['node_modules'],
  96. transforms: ['typescript']
  97. }),
  98. resolve({
  99. // pass custom options to the resolve plugin
  100. customResolveOptions: {
  101. moduleDirectories: ['node_modules']
  102. }
  103. })
  104. ],
  105. external: [
  106. ...Object.keys(pkg.dependencies || {}),
  107. ...Object.keys(pkg.peerDependencies || {})
  108. ]
  109. }
  110. ]