rollup.config.js 2.7 KB

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