-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.config.js
32 lines (29 loc) · 1.04 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
/* eslint-disable @typescript-eslint/no-var-requires */
const { build } = require('esbuild');
// Common build options
const buildOptions = {
entryPoints: ['src/index.ts'], // Your input file
bundle: true, // Bundle your package
platform: 'browser', // Target platform for browser
target: 'es2020', // Target ECMAScript version
minify: true, // Minify the output
external: ['react', 'react-dom', '@neosh11/autocomplete-search'], // Mark 'react' and 'react-dom' as external dependencies
loader: {
'.ts': 'tsx', // Load TypeScript files as TSX
},
define: {
'process.env.NODE_ENV': '"production"', // Define the NODE_ENV as production for React
},
};
// Build CJS output
build({
...buildOptions,
outfile: 'dist/bundle.cjs.js', // Your output file for CJS
format: 'cjs', // Output format as CommonJS
}).catch(() => process.exit(1));
// Build ESM output
build({
...buildOptions,
outfile: 'dist/bundle.esm.js', // Your output file for ESM
format: 'esm', // Output format as ECMAScript Modules
}).catch(() => process.exit(1));