forked from suiet/wallet-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
48 lines (45 loc) · 1.29 KB
/
rollup.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import resolvePlugin from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import cjs2es from '@rollup/plugin-commonjs';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import { defineConfig } from 'rollup';
import {getBabelOutputPlugin} from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
import * as path from 'path';
const config = defineConfig({
input: 'src/index.ts',
output: [
{
file: 'dist/index.js',
format: 'es',
plugins: [
// compile js to es5 compatible, friendly to browsers
getBabelOutputPlugin({
filename: 'dist/index.js',
configFile: path.resolve(__dirname, 'babel.config.js'),
})
]
},
{
file: 'dist/index.cjs',
format: 'cjs',
},
],
external: ['@mysten/sui.js'],
plugins: [
// compile ts files
typescript(),
// polyfill nodejs built-in and global modules
nodePolyfills(),
// fetch node_modules contents
resolvePlugin({
browser: true, // specify that it's built for browser
}),
// convert commonjs module to es module for rollup to bundle
cjs2es(),
],
});
if (process.env.NODE_ENV === 'production') {
config.plugins?.push(terser()); // minify output files
}
export default config;