forked from warp-contracts/warp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.js
54 lines (47 loc) · 1.12 KB
/
bundle.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
const { build } = require('esbuild');
const rimraf = require('rimraf');
const fs = require('fs');
const clean = async () => {
return new Promise((resolve) => {
rimraf('./bundles', () => resolve());
});
};
const runBuild = async () => {
await clean();
const buildConfig = {
entryPoints: ['./src/index.ts'],
bundle: true,
platform: 'browser',
target: ['esnext'],
format: 'esm',
globalName: 'warp'
};
console.log('Building web bundle esm.');
const result = await build({
...buildConfig,
minify: true,
outfile: './bundles/web.bundle.min.js'
}).catch((e) => {
console.log(e);
process.exit(1);
});
/*fs.writeFileSync('metadata.json', JSON.stringify({
inputs: result.metafile.inputs,
outputs: result.metafile.outputs
}));*/
console.log('Building web bundle iife.');
await build({
...buildConfig,
minify: true,
target: ['esnext'],
format: 'iife',
outfile: './bundles/web.iife.bundle.min.js'
}).catch((e) => {
console.log(e);
process.exit(1);
});
};
runBuild().finally(() => {
console.log('Build done.');
});
module.exports = runBuild;