rollup.config.js 2.5 KB

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