rollup.config.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. },
  31. treeshake: true,
  32. perf: true,
  33. output: [
  34. {
  35. dir: 'dist/',
  36. entryFileNames: '[name].cjs',
  37. format: 'cjs',
  38. chunkFileNames: '[name]-[hash].cjs',
  39. exports: 'named',
  40. globals: {}
  41. },
  42. {
  43. dir: 'dist/',
  44. entryFileNames: '[name].js',
  45. format: 'esm',
  46. exports: 'named',
  47. globals: {}
  48. }
  49. ],
  50. plugins: [
  51. commonjs({}),
  52. resolve({
  53. // pass custom options to the resolve plugin
  54. customResolveOptions: {
  55. moduleDirectories: ['node_modules']
  56. }
  57. }),
  58. typescript({
  59. tsconfig: './tsconfig.json'
  60. }),
  61. babel({
  62. configFile: false,
  63. presets: [['@babel/preset-env'], ['@babel/preset-typescript']]
  64. }),
  65. terser()
  66. ],
  67. external: [
  68. ...Object.keys(pkg.dependencies || {}),
  69. ...Object.keys(pkg.peerDependencies || {})
  70. ]
  71. },
  72. {
  73. input: {
  74. bundle: './src/bundle.ts'
  75. },
  76. output: [
  77. {
  78. name: '__TAURI__',
  79. dir: '../../core/tauri/scripts',
  80. entryFileNames: 'bundle.js',
  81. format: 'umd',
  82. plugins: [
  83. getBabelOutputPlugin({
  84. presets: [['@babel/preset-env', { modules: 'umd' }]],
  85. allowAllFormats: true
  86. }),
  87. terser()
  88. ],
  89. globals: {}
  90. }
  91. ],
  92. plugins: [
  93. sucrase({
  94. exclude: ['node_modules'],
  95. transforms: ['typescript']
  96. }),
  97. resolve({
  98. // pass custom options to the resolve plugin
  99. customResolveOptions: {
  100. moduleDirectories: ['node_modules']
  101. }
  102. })
  103. ],
  104. external: [
  105. ...Object.keys(pkg.dependencies || {}),
  106. ...Object.keys(pkg.peerDependencies || {})
  107. ]
  108. }
  109. ]