-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
108 lines (102 loc) · 2.42 KB
/
Copy pathrollup.config.mjs
File metadata and controls
108 lines (102 loc) · 2.42 KB
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
import typescript from '@rollup/plugin-typescript';
import replace from '@rollup/plugin-replace';
import json from '@rollup/plugin-json';
import pkg from './package.json' with { type: 'json' };
/**
* @type {import('rollup').OutputOptions['chunkFileNames']}
*/
const chunkFileNames = (chunkInfo) => {
if (chunkInfo.name.includes('CallStatsLatencyChart')) {
return 'latency-chart-[hash].[format].js';
}
if (chunkInfo.name.includes('BackgroundFilters')) {
return 'background-filters-[hash].[format].js';
}
return '[name]-[hash].[format].js';
};
const commonPlugins = [
json(),
replace({
preventAssignment: true,
'process.env.PKG_NAME': JSON.stringify(pkg.name),
'process.env.PKG_VERSION': JSON.stringify(pkg.version),
}),
];
/**
* Main entrypoint configuration
*/
const mainConfig = {
input: 'index.ts',
output: [
{
dir: 'dist',
entryFileNames: 'index.es.js',
format: 'es',
sourcemap: true,
chunkFileNames,
},
{
dir: 'dist',
entryFileNames: 'index.cjs.js',
format: 'cjs',
sourcemap: true,
chunkFileNames,
},
],
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
'react/jsx-runtime',
'react/jsx-dev-runtime',
],
plugins: [
...commonPlugins,
typescript({
tsconfig:
process.env.NODE_ENV === 'production'
? './tsconfig.production.json'
: './tsconfig.json',
}),
],
};
/**
* Embedded entrypoint configuration
*/
const embeddedConfig = {
input: 'embedded.ts',
output: [
{
dir: 'dist',
entryFileNames: 'embedded.es.js',
format: 'es',
sourcemap: true,
chunkFileNames: (chunkInfo) =>
`embedded-${chunkInfo.name}-[hash].[format].js`,
},
{
dir: 'dist',
entryFileNames: 'embedded.cjs.js',
format: 'cjs',
sourcemap: true,
chunkFileNames: (chunkInfo) =>
`embedded-${chunkInfo.name}-[hash].[format].js`,
},
],
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
'@stream-io/audio-filters-web',
'react/jsx-runtime',
'react/jsx-dev-runtime',
],
plugins: [
...commonPlugins,
typescript({
tsconfig:
process.env.NODE_ENV === 'production'
? './tsconfig.production.json'
: './tsconfig.json',
}),
],
};
export default [mainConfig, embeddedConfig];