-
Notifications
You must be signed in to change notification settings - Fork 32
/
rollup.config.mjs
66 lines (61 loc) · 2.07 KB
/
rollup.config.mjs
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
import * as dotenv from 'dotenv';
dotenv.config();
import replace from '@rollup/plugin-replace';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import commonJS from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import { readFileSync } from 'fs';
const packageLock = JSON.parse(
readFileSync('package-lock.json', { encoding: 'utf8' })
);
// This works fine after node 16.15, but does not work previous to that with the recent versions of rollup
//import packageLock from './package-lock.json' assert { type: 'json' };
const version = packageLock.version;
const mode = process.env.NODE_ENV || 'production';
const devCallMachineUrl =
process.env.DEV_CALL_MACHINE_URL ||
'https://khk-local.wss.daily.co:8000/static/call-machine-object-bundle.js';
const sentryDSN =
'https://[email protected]/168844';
function makeConfig({ legacyFileName = false } = {}) {
return {
input: 'src/module.js',
output: [
{
file: legacyFileName ? 'dist/daily-iframe-esm.js' : 'dist/daily-esm.js',
format: 'es',
},
],
plugins: [
nodeResolve({
preferBuiltins: false,
}),
replace({
'process.env.NODE_ENV': JSON.stringify(mode),
__dailyJsVersion__: JSON.stringify(version),
__devCallMachineUrl__: JSON.stringify(devCallMachineUrl),
__sentryDSN__: JSON.stringify(sentryDSN),
}),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
presets: [
['@babel/preset-env', { exclude: ['transform-regenerator'] }],
],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-class-properties',
],
}),
commonJS({
include: 'node_modules/**',
namedExports: {
'node_modules/lodash/lodash.js': ['orderBy', 'filter'],
},
}),
mode === 'production' && terser(), // minify in production
],
};
}
export default [makeConfig({ legacyFileName: true }), makeConfig()];