forked from Vanilagy/mp4-muxer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
46 lines (39 loc) · 1019 Bytes
/
build.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
import * as esbuild from 'esbuild';
const baseConfig = {
entryPoints: ['src/index.ts'],
bundle: true,
logLevel: 'info'
};
const umdConfig = {
...baseConfig,
format: 'iife',
// The following are hacks to basically make this an UMD module. No native support for that in esbuild as of today
globalName: 'Mp4Muxer',
footer: {
js:
`if (typeof module === "object" && typeof module.exports === "object") Object.assign(module.exports, Mp4Muxer)`
}
};
const esmConfig = {
...baseConfig,
format: 'esm'
};
let ctxUmd = await esbuild.context({
...umdConfig,
outfile: 'build/mp4-muxer.js'
});
let ctxEsm = await esbuild.context({
...esmConfig,
outfile: 'build/mp4-muxer.mjs'
});
let ctxUmdMinified = await esbuild.context({
...umdConfig,
outfile: 'build/mp4-muxer.min.js',
minify: true
});
let ctxEsmMinified = await esbuild.context({
...esmConfig,
outfile: 'build/mp4-muxer.min.mjs',
minify: true
});
await Promise.all([ctxUmd.watch(), ctxEsm.watch(), ctxUmdMinified.watch(), ctxEsmMinified.watch()]);