-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.config.prod.mjs
45 lines (41 loc) · 999 Bytes
/
esbuild.config.prod.mjs
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
// @ts-check
import * as esbuild from 'esbuild'
import { nodeExternalsPlugin } from 'esbuild-node-externals'
import alias from 'esbuild-plugin-alias'
import { commonjs } from "@hyrious/esbuild-plugin-commonjs"
import { esbuildDecorators } from 'esbuild-plugin-ts-decorators'
/**
* @param {import('esbuild').BuildOptions} options
*/
async function main(options) {
const context = await esbuild.context(options)
const watch = process.argv.slice(2).includes('--watch')
if (watch) {
context.watch()
} else {
await context.rebuild()
await context.dispose()
}
}
main({
plugins: [
commonjs(),
alias({
'@': './src',
}),
esbuildDecorators({
tsconfig: './tsconfig.json',
cwd: process.cwd(),
}),
nodeExternalsPlugin(),
],
splitting: true,
entryPoints: { '': './src/index.ts' },
outExtension: { '.js': '.mjs' },
outdir: './dist/',
bundle: true,
format: 'esm',
sourcemap: true,
treeShaking: true,
logLevel: 'debug',
})