-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathesbuild.js
55 lines (50 loc) · 1.27 KB
/
esbuild.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
55
const fs = require('fs')
const esbuild = require('esbuild')
const { nodeExternalsPlugin } = require('esbuild-node-externals')
const { sassPlugin } = require('esbuild-sass-plugin')
const { minifyTemplates, writeFiles } = require('esbuild-minify-templates')
const baseTsConfig = {
entryPoints: ['./src/index.ts', './src/connections.ts', './src/networks.ts'],
bundle: true,
minify: true,
treeShaking: true,
write: false,
metafile: true,
external: ['react'],
plugins: [
nodeExternalsPlugin({
allowList: ['@broxus/tvm-connect'],
}),
sassPlugin(),
minifyTemplates(),
writeFiles(),
],
loader: {
'.svg': 'dataurl',
},
}
esbuild.build({
entryPoints: ['./src/styles.scss'],
minify: true,
plugins: [sassPlugin()],
outfile: 'dist/styles.css',
})
esbuild
.build({
...baseTsConfig,
format: 'esm',
outdir: 'dist/esm'
})
.then(result => {
fs.writeFileSync('./buildmeta.json', JSON.stringify(result.metafile, null, 2))
fs.unlinkSync('./dist/esm/index.css')
})
esbuild
.build({
...baseTsConfig,
format: 'cjs',
outdir: 'dist/cjs'
})
.then(() => {
fs.unlinkSync('./dist/cjs/index.css')
})