2020-06-27 18:20:00 +03:00
|
|
|
// 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'
|
2020-07-06 16:16:01 +03:00
|
|
|
import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel'
|
|
|
|
import typescript from '@rollup/plugin-typescript'
|
2020-06-27 18:20:00 +03:00
|
|
|
import pkg from './package.json'
|
|
|
|
|
|
|
|
export default [{
|
|
|
|
input: {
|
|
|
|
'fs': './api-src/fs.ts',
|
|
|
|
'dialog': './api-src/dialog.ts',
|
|
|
|
'event': './api-src/event.ts',
|
|
|
|
'http': './api-src/http.ts',
|
|
|
|
'index': './api-src/index.ts',
|
|
|
|
'process': './api-src/process.ts',
|
|
|
|
'tauri': './api-src/tauri.ts',
|
|
|
|
'window': './api-src/window.ts',
|
2020-07-03 19:47:30 +03:00
|
|
|
'cli': './api-src/cli.ts',
|
|
|
|
'notification': './api-src/notification.ts',
|
2020-06-27 18:20:00 +03:00
|
|
|
},
|
|
|
|
treeshake: true,
|
|
|
|
perf: true,
|
|
|
|
output: [
|
|
|
|
{
|
2020-07-06 16:16:01 +03:00
|
|
|
dir: 'api/',
|
2020-06-27 18:20:00 +03:00
|
|
|
entryFileNames: '[name].js',
|
|
|
|
format: 'cjs',
|
|
|
|
exports: 'named',
|
|
|
|
globals: {}
|
|
|
|
},
|
|
|
|
{
|
2020-07-06 16:16:01 +03:00
|
|
|
dir: 'api/',
|
|
|
|
entryFileNames: '[name].mjs',
|
2020-06-27 18:20:00 +03:00
|
|
|
format: 'esm',
|
|
|
|
exports: 'named',
|
|
|
|
globals: {}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
plugins: [
|
|
|
|
commonjs({}),
|
|
|
|
resolve({
|
|
|
|
// pass custom options to the resolve plugin
|
|
|
|
customResolveOptions: {
|
|
|
|
moduleDirectory: 'node_modules'
|
|
|
|
}
|
2020-07-06 16:16:01 +03:00
|
|
|
}),
|
|
|
|
typescript({
|
|
|
|
tsconfig: './api-src/tsconfig.json'
|
|
|
|
}),
|
|
|
|
babel({
|
|
|
|
configFile: false,
|
|
|
|
presets: [
|
|
|
|
['@babel/preset-env'],
|
|
|
|
['@babel/preset-typescript']
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
terser()
|
2020-06-27 18:20:00 +03:00
|
|
|
],
|
|
|
|
external: [
|
|
|
|
...Object.keys(pkg.dependencies || {}),
|
|
|
|
...Object.keys(pkg.peerDependencies || {})
|
|
|
|
],
|
|
|
|
watch: {
|
|
|
|
chokidar: true,
|
|
|
|
include: 'api-src/**',
|
|
|
|
exclude: 'node_modules/**'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: {
|
|
|
|
'bundle': './api-src/bundle.ts'
|
|
|
|
},
|
|
|
|
output: [{
|
|
|
|
name: '__TAURI__',
|
|
|
|
dir: 'api/', // if it needs to run in the browser
|
|
|
|
entryFileNames: 'tauri.bundle.umd.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: {
|
|
|
|
moduleDirectory: 'node_modules'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
external: [
|
|
|
|
...Object.keys(pkg.dependencies || {}),
|
|
|
|
...Object.keys(pkg.peerDependencies || {})
|
|
|
|
]
|
|
|
|
}]
|