-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.config.js
54 lines (46 loc) · 1.36 KB
/
esbuild.config.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
import { build } from 'esbuild'
import { nodeExternalsPlugin } from 'esbuild-node-externals'
import { config } from 'dotenv'
import { resolve, dirname } from 'path'
import { URL, fileURLToPath } from 'url'
import { readdirSync } from 'fs'
config()
const moduleURL = new URL(import.meta.url)
const __dirname = dirname(fileURLToPath(moduleURL))
const commandsFolderPath = resolve(__dirname, './src/commands')
const commandFiles = readdirSync(commandsFolderPath)
const eventsFolderPath = resolve(__dirname, './src/events')
const eventFiles = readdirSync(eventsFolderPath)
const getFilePath = (file) => {
if (!file.endsWith('.ts') && file.includes('.')) return
if (!file.endsWith('.ts')) return file + '/index.ts'
return file
}
build({
entryPoints: [
'src/index.ts',
...commandFiles.map((file) => getFilePath(`src/commands/${file}`)),
...eventFiles.map((file) => getFilePath(`src/events/${file}`))
],
splitting: true,
bundle: true,
platform: 'node',
target: 'es2022',
format: 'esm',
minify: true,
outdir: 'dist',
plugins: [nodeExternalsPlugin()],
alias: {
'#': './src',
'@/utils': './src/utils',
'@/commands': './src/commands',
'@/types': './src/types',
'@/events': './src/events',
'@/services': './src/services',
'@/entity': './src/entity'
}
})
.catch((err) => {
console.error(err)
process.exit(1)
})