rollup.config.js 2.7 KB

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