-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.js
58 lines (54 loc) · 1.42 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
import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json';
import alias from '@rollup/plugin-alias';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import license from 'rollup-plugin-license';
import commonjs from '@rollup/plugin-commonjs';
import packageJson from './package.json';
const TERSER_CONFIG = {
output: {
comments: false,
},
};
const LICENSE_CONFIG = {
banner: {
commentStyle: 'ignored',
content: `gmp-wasm v${packageJson.version} (https://www.npmjs.com/package/gmp-wasm)
(c) Dani Biro
@license LGPL-3.0`,
},
};
const getBundleConfig = (miniLib = false, minified = false) => ({
input: 'src/index.ts',
output: [
{
file: `dist/${miniLib ? 'mini' : 'index'}.umd${minified ? '.min' : ''}.js`,
name: 'gmp',
format: 'umd',
},
{
file: `dist/${miniLib ? 'mini' : 'index'}.esm${minified ? '.min' : ''}.js`,
format: 'es',
},
],
plugins: [
alias({
entries: [
{ find: 'gmpwasmts', replacement: `../${miniLib ? 'gmpmini' : 'gmp'}.wasm.ts` }
]
}),
nodeResolve(),
commonjs(),
json(),
typescript(),
...(minified ? [terser(TERSER_CONFIG)]: []),
license(LICENSE_CONFIG),
],
});
export default [
getBundleConfig(false, false),
getBundleConfig(false, true),
getBundleConfig(true, false),
getBundleConfig(true, true)
];