-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrollup.config.js
84 lines (77 loc) · 2.13 KB
/
rollup.config.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//import path from "path";
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import typescript from "@rollup/plugin-typescript";
import json from "@rollup/plugin-json";
import replace from "@rollup/plugin-replace";
//import analyze from 'rollup-plugin-analyzer';
const production = !process.env.ROLLUP_WATCH;
export default {
input: './src/index.ts',
output: [
{
sourcemap: true,
format: 'cjs',
file: 'dist/index.js'
},
{
sourcemap: true,
format: 'esm',
file: 'dist.esm/index.js'
}
],
external: [
'@elastosfoundation/did-js-sdk',
'web3',
'web3-core',
'moment',
'rxjs',
'@walletconnect/client',
'@walletconnect/web3-provider',
'@walletconnect/utils',
// TODO: theoretically we shouldn't have to remove this manually, as we don't include it ourselves.
// But can't find the parent dependency for now.
'bn.js',
],
plugins: [
postcss({
extract: 'bundle.css'
}),
json(),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['@elastosfoundation/did-js-sdk'],
preferBuiltins: true
}),
commonjs(),
typescript({
sourceMap: true,
inlineSources: !production
}),
// To fix the "exports is not defined" runtime error in browser because some dependencies of
// wallet connect have code that generates calls to "exports" which doesn't exist in browsers.
// https://github.com/rollup/rollup/issues/2332
// https://github.com/microsoft/TypeScript/issues/32934
replace({
'Object.defineProperty(exports, "__esModule", { value: true });': '',
delimiters: ['\n', '\n'],
preventAssignment: true
}),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser(),
/*analyze({
limit: 10
})*/
],
watch: {
clearScreen: true
}
};