-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathrollup.config.js
81 lines (71 loc) · 1.92 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
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
const env = process.env.NODE_ENV;
const devMode = (env === 'development');
const banner = `/*! webauthn-ui library (C) 2018 - ${new Date().getFullYear()} Thomas Bleeker (www.madwizard.org) - MIT license */\n`;
function cleanup() {
// Note: it is allowed to remove the (rather large) tslib 0BSD license notice.
// See https://github.com/microsoft/tslib/issues/47
return {
name: 'cleanup',
renderChunk(code) {
let replaced = code.replace(/\/\*![^M/]+Microsoft Corporation[\s\S]+?\*\//, '/* Microsoft tslib 0BSD licensed */');
replaced = replaced.replace(/\r\n/g, '\n');
return { code: replaced, map: null };
},
};
}
const tsPluginOpts = {
useTsconfigDeclarationDir: true,
};
const builds = [
{
input: './src/index.ts',
output: {
file: 'dist/umd/webauthn-ui.js',
format: 'umd',
name: 'WebAuthnUI',
banner,
sourcemap: devMode,
},
plugins: [typescript(tsPluginOpts), cleanup()],
},
{
input: './src/index.ts',
output: {
file: 'dist/es/webauthn-ui.js',
format: 'es',
banner,
sourcemap: devMode,
},
plugins: [typescript(tsPluginOpts), cleanup()],
},
];
if (!devMode) {
builds.push(
{
input: './src/index.ts',
output: {
file: 'dist/umd/webauthn-ui.min.js',
format: 'umd',
name: 'WebAuthnUI',
banner,
sourcemap: devMode,
},
plugins: [typescript(tsPluginOpts), terser({ output: { comments: /webauthn-ui/ } }), cleanup()],
},
);
builds.push(
{
input: './src/index.ts',
output: {
file: 'dist/es/webauthn-ui.min.js',
format: 'es',
banner,
sourcemap: devMode,
},
plugins: [typescript(tsPluginOpts), terser({ output: { comments: /webauthn-ui/ } }), cleanup()],
},
);
}
export default builds;