-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.js
55 lines (53 loc) · 1.37 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'],
bundle: true,
minify: true,
treeShaking: true,
write: false,
metafile: true,
external: ['react'],
plugins: [
nodeExternalsPlugin({
allowList: ['@broxus/tvm-connect']
}),
sassPlugin(),
minifyTemplates(),
writeFiles()
],
loader: {
'.svg': 'dataurl'
}
}
Promise.all([
esbuild.build({
entryPoints: ['./src/styles.scss'],
minify: true,
plugins: [
sassPlugin(),
],
outfile: 'dist/styles.css',
}),
esbuild.build({
...baseTsConfig,
format: 'esm',
outfile: 'dist/index.esm.js',
})
.then(result => {
fs.writeFileSync('./buildmeta.json', JSON.stringify(result.metafile, null, 2));
fs.unlinkSync('./dist/index.esm.css')
}),
esbuild.build({
...baseTsConfig,
format: 'cjs',
outfile: 'dist/index.cjs.js',
})
.then(() => {
fs.unlinkSync('./dist/index.cjs.css')
}),
])
.catch(() => process.exit(1));