-
Notifications
You must be signed in to change notification settings - Fork 5
/
esbuild.config.cjs
51 lines (49 loc) · 1.3 KB
/
esbuild.config.cjs
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
/* eslint-disable @typescript-eslint/no-require-imports */
const esbuild = require('esbuild');
const path = require('path');
const fs = require('fs');
esbuild
.build({
inject: [require.resolve('node-stdlib-browser/helpers/esbuild/shim')],
format: 'esm',
entryPoints: ['./src/elven.ts'],
bundle: true,
metafile: true,
minify: true,
outdir: 'build',
platform: 'browser',
plugins: [
{
name: 'alias',
setup(build) {
build.onResolve({ filter: /^bignumber\.js$/ }, () => {
return {
path: path.resolve(
__dirname,
'node_modules/bignumber.js/bignumber.mjs'
),
};
});
build.onResolve({ filter: /^buffer$/ }, () => {
return {
path: path.resolve(
__dirname,
'node_modules/node-stdlib-browser/node_modules/buffer/index.js'
),
};
});
},
},
],
})
.then((result) => {
fs.writeFileSync('./build/meta.json', JSON.stringify(result.metafile));
return result;
})
.then((result) => {
return esbuild.analyzeMetafile(result.metafile);
})
.then((result) => {
fs.writeFileSync('./build/meta.txt', result);
})
.catch(() => process.exit(1));