forked from ReachFive/identity-web-ui-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
113 lines (107 loc) · 3.05 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import url from '@rollup/plugin-url'
import svg from '@svgr/rollup'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
import pkg from './package.json' assert { type: 'json' }
const dependencies = Object.keys(pkg.dependencies)
const banner = [
`/**`,
` * ${pkg.name} - v${pkg.version}`,
` * Compiled ${(new Date()).toUTCString().replace(/GMT/g, 'UTC')}`,
` *`,
` * Copyright (c) ReachFive.`,
` *`,
` * This source code is licensed under the MIT license found in the`,
` * LICENSE file in the root directory of this source tree.`,
` **/`,
].join('\n');
// Ignore Luxon library's circular dependencies
function onWarn(message) {
if ( message.code === 'CIRCULAR_DEPENDENCY' ) return;
console.warn( message);
}
const bundle = config => ({
...config,
input: 'src/index.ts',
})
const plugins = [
replace({
preventAssignment: true,
values: {
'process.env.NODE_ENV': JSON.stringify('production'),
}
}),
nodeResolve({
extensions: ['.jsx', '.js', '.json'],
preferBuiltins: true
}),
commonjs({ include: /node_modules/ }),
svg(),
// Add an inlined version of SVG files: https://www.smooth-code.com/open-source/svgr/docs/rollup/#using-with-url-plugin
url({ limit: Infinity, include: ['**/*.svg'] }),
esbuild(),
]
export default [
bundle({
plugins,
external: dependencies,
output: [
{
banner,
file: 'cjs/identity-ui.js',
format: 'cjs',
sourcemap: true,
},
{
banner,
file: 'es/identity-ui.js',
format: 'es',
sourcemap: true,
},
{
file: 'es/identity-ui.min.js',
format: 'es',
plugins: [terser({ output: { preamble: banner } })],
sourcemap: true,
},
],
onwarn: onWarn
}),
bundle({
plugins,
output: [
{
banner,
file: 'umd/identity-ui.js',
format: 'umd',
name: 'reach5Widgets',
sourcemap: true,
globals: { '@reachfive/identity-core': 'reach5' },
},
{
file: 'umd/identity-ui.min.js',
format: 'umd',
name: 'reach5Widgets',
plugins: [terser({ output: { preamble: banner } })],
sourcemap: true,
globals: { '@reachfive/identity-core': 'reach5' },
},
],
onwarn: onWarn
}),
bundle({
plugins: [
dts()
],
output: {
banner,
file: 'types/identity-ui.d.ts',
format: 'es',
},
onwarn: onWarn
}),
]