-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.config.ts
67 lines (62 loc) · 1.77 KB
/
build.config.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
/**
* @file Configuration - Build
* @module config/build
* @see https://github.com/flex-development/mkbuild
*/
import { defineBuildConfig, type Config } from '@flex-development/mkbuild'
import pathe from '@flex-development/pathe'
import { at, pick } from '@flex-development/tutils'
import type * as esbuild from 'esbuild'
import pkg from './package.json' assert { type: 'json' }
import tsconfig from './tsconfig.build.json' assert { type: 'json' }
/**
* Build configuration options.
*
* @const {Config} config
*/
const config: Config = defineBuildConfig({
bundle: true,
charset: 'utf8',
conditions: tsconfig.compilerOptions.customConditions,
dts: false,
external: [
'@nestjs/microservices',
'@nestjs/platform-express',
'@nestjs/websockets',
'class-transformer',
'class-validator',
'node-fetch'
],
platform: 'node',
plugins: [
{
name: 'pkg',
/**
* Tree shake `package.json` imports.
*
* [1]: https://esbuild.github.io/plugins
*
* @param {esbuild.PluginBuild} build - [esbuild plugin api][1]
* @param {esbuild.PluginBuild['onLoad']} build.onLoad - Load callback
* @return {void} Nothing when complete
*/
setup({ onLoad }: esbuild.PluginBuild): void {
return void onLoad({ filter: /package\.json$/ }, args => {
if (args.path === pathe.resolve('package.json')) {
return {
contents: JSON.stringify(pick(pkg, ['name', 'version']), null, 2),
loader: 'json'
}
}
return null
})
}
}
],
source: 'src/main.ts',
sourcemap: true,
sourcesContent: false,
target: 'node' + at(/([\d.]+)/.exec(pkg.engines.node), 0, ''),
tsconfig: 'tsconfig.build.json'
})
export default config