-
Notifications
You must be signed in to change notification settings - Fork 20
/
esbuild.config.cjs
40 lines (35 loc) · 1.04 KB
/
esbuild.config.cjs
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
// @ts-check
/* No need to import/require dotenv because serverless.yml has `useDotenv: true` */
const isProduction = process.env.NODE_ENV === 'production'
/** @type {Array<import('esbuild').Plugin>} */
const plugins = []
if (!isProduction) {
// @ts-ignore - esbuild-analyzer doesn't come with types
const AnalyzerPlugin = require('esbuild-analyzer')
plugins.push(
AnalyzerPlugin({
outfile: './.esbuild/esbuild-analyzer.html',
}),
)
}
/**
* @param {import('serverless').Options} _
* @returns {import('esbuild').BuildOptions & { packager: string, concurrency: number; watch: import('esbuild').WatchOptions; keepOutputDirectory?: boolean; }}
*/
module.exports = (_) => ({
packager: 'pnpm',
concurrency: 4,
bundle: true,
format: 'cjs',
keepNames: true,
target: 'node18',
platform: 'node',
minify: isProduction,
drop: isProduction ? ['console', 'debugger'] : [],
metafile: !isProduction,
plugins,
watch: {
pattern: ['src/**/*.ts'],
ignore: ['.serverless/**/*', '.build', 'dist', 'node_modules', 'test'],
},
})