tauri/tooling/api/rollup.config.js
Laegel fcb3b4857e
fix: #1512 (#1517)
* fix: Export

* chore(changefile)

* fix: Updated publish step

* fix: Also outputting CommonJS

* fix:`preparePublish` now copies the necessary files

* fix: typo

Co-authored-by: Laegel <valentin.chouaf@laposte.net>

* chore: update `build` script

* chore: add `prepublishOnly script`

* chore: update `api` covector config

* round two, fight!!

Co-authored-by: amrbashir <48618675+amrbashir@users.noreply.github.com>
2021-04-18 22:31:12 -05:00

110 lines
2.7 KiB
JavaScript

// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
// rollup.config.js
import { terser } from 'rollup-plugin-terser'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import sucrase from '@rollup/plugin-sucrase'
import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel'
import typescript from '@rollup/plugin-typescript'
import pkg from './package.json'
export default [
{
input: {
app: './src/app.ts',
fs: './src/fs.ts',
path: './src/path.ts',
dialog: './src/dialog.ts',
event: './src/event.ts',
updater: './src/updater.ts',
http: './src/http.ts',
index: './src/index.ts',
shell: './src/shell.ts',
tauri: './src/tauri.ts',
window: './src/window.ts',
cli: './src/cli.ts',
notification: './src/notification.ts',
globalShortcut: './src/globalShortcut.ts'
},
treeshake: true,
perf: true,
output: [
{
dir: 'dist/',
entryFileNames: '[name].js',
format: 'cjs',
exports: 'named',
globals: {}
},
{
dir: 'dist/',
entryFileNames: '[name].mjs',
format: 'esm',
exports: 'named',
globals: {}
}
],
plugins: [
commonjs({}),
resolve({
// pass custom options to the resolve plugin
customResolveOptions: {
moduleDirectories: ['node_modules']
}
}),
typescript({
tsconfig: './tsconfig.json'
}),
babel({
configFile: false,
presets: [['@babel/preset-env'], ['@babel/preset-typescript']]
}),
terser()
],
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {})
]
},
{
input: {
bundle: './src/bundle.ts'
},
output: [
{
name: '__TAURI__',
dir: '../../core/tauri/scripts',
entryFileNames: 'bundle.js',
format: 'umd',
plugins: [
getBabelOutputPlugin({
presets: [['@babel/preset-env', { modules: 'umd' }]],
allowAllFormats: true
}),
terser()
],
globals: {}
}
],
plugins: [
sucrase({
exclude: ['node_modules'],
transforms: ['typescript']
}),
resolve({
// pass custom options to the resolve plugin
customResolveOptions: {
moduleDirectories: ['node_modules']
}
})
],
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {})
]
}
]