-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
46 lines (41 loc) · 1.27 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
/* eslint-disable @typescript-eslint/no-var-requires */
const typescript = require("rollup-plugin-typescript2");
const commonjs = require("@rollup/plugin-commonjs");
const replace = require("@rollup/plugin-replace");
const pkg = require("./package.json");
const { dts } = require("rollup-plugin-dts");
const dependencies = [...Object.keys(pkg.dependencies || {})];
const peerDependencies = [...Object.keys(pkg.peerDependencies || {})];
const tsOptions = {
tsconfig: "tsconfig.build.json",
};
const plugins = [
replace({
preventAssignment: true,
// jslib-media uses global.navigator for some gUM calls, replace these
delimiters: [" ", "."],
values: { "global.navigator.mediaDevices": " navigator.mediaDevices." },
}),
commonjs(),
typescript(tsOptions),
];
const external = [...dependencies, ...peerDependencies];
module.exports = [
// Esm build of lib, to be used with bundlers
{
input: "src/index.ts",
output: {
file: "dist/index.esm.js",
format: "esm",
exports: "named",
},
plugins,
external,
},
{
input: "src/index.ts",
output: [{ file: "dist/index.d.ts", format: "es" }],
external,
plugins: [dts(tsOptions)],
},
];