-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.config.js
More file actions
27 lines (24 loc) · 872 Bytes
/
esbuild.config.js
File metadata and controls
27 lines (24 loc) · 872 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
import esbuild from 'esbuild';
import { execSync } from 'child_process';
// Generate TypeScript types
execSync('tsc --emitDeclarationOnly --declaration --outDir dist', { stdio: 'inherit' });
// Build configurations
const builds = [
{ format: 'cjs', minify: true, outfile: 'dist/index.min.js' }, // Minified CJS
{ format: 'esm', minify: true, outfile: 'dist/index.esm.min.js' }, // Minified ESM
{ format: 'cjs', minify: false, outfile: 'dist/index.js' }, // Unminified CJS
{ format: 'esm', minify: false, outfile: 'dist/index.esm.js' }, // Unminified ESM
];
// Run esbuild for each configuration
Promise.all(builds.map(({ format, minify, outfile }) =>
esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
minify,
sourcemap: true,
target: 'esnext',
external: [],
format,
outfile,
})
)).catch(() => process.exit(1));