-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.config.js
36 lines (33 loc) · 996 Bytes
/
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
33
34
35
36
// https://souporserious.com/bundling-typescript-with-esbuild-for-npm/
const { build } = require('esbuild');
const { nodeExternalsPlugin } = require('esbuild-node-externals');
const { clean } = require('esbuild-plugin-clean');
const { replace } = require('esbuild-plugin-replace');
const path = require('path');
const bfs = require('@jswork/banner-defaults');
const pkg = require(path.join(process.cwd(), './package.json'));
require('@jswork/next-nice-comments');
const shared = {
entryPoints: ['src/index.ts'],
bundle: true,
minify: true,
platform: 'node',
sourcemap: true,
target: 'node14',
banner: {
js: nx.niceComments(bfs(pkg), 'js'),
},
plugins: [
clean({
patterns: ['./dist/*'],
}),
nodeExternalsPlugin(),
replace({
'export default ': 'export = ',
'__VERSION__': pkg.version,
}),
],
};
// build cjs + esm
build({ ...shared, outfile: 'dist/index.cjs.js' });
build({ ...shared, outfile: 'dist/index.esm.js', format: 'esm' });