-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
44 lines (38 loc) · 997 Bytes
/
Copy pathesbuild.js
File metadata and controls
44 lines (38 loc) · 997 Bytes
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
import esbuild from 'esbuild'
import { nodeExternalsPlugin } from 'esbuild-node-externals'
import FastGlob from 'fast-glob'
import { commonjs } from '@hyrious/esbuild-plugin-commonjs'
async function main() {
const mainConfig = {
entryPoints: ['src/main.ts'],
bundle: true,
outdir: 'dist',
platform: 'node',
target: 'node14',
plugins: [nodeExternalsPlugin(), commonjs()],
sourcemap: true,
format: 'esm',
}
const testEntries = await FastGlob('test/**/*.ts')
const testConfig = {
entryPoints: testEntries,
bundle: true,
outdir: 'dist/test',
platform: 'node',
target: 'node14',
plugins: [nodeExternalsPlugin(), commonjs()],
sourcemap: true,
format: 'esm',
}
async function build(config) {
if (process.argv.includes('--watch')) {
const context = await esbuild.context(config)
await context.watch()
} else {
await esbuild.build(config)
}
}
build(mainConfig)
build(testConfig)
}
main()