-
Notifications
You must be signed in to change notification settings - Fork 4
/
esbuild.js
45 lines (43 loc) · 932 Bytes
/
esbuild.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
37
38
39
40
41
42
43
44
45
import fileloc from 'esbuild-plugin-fileloc';
import { clean } from 'esbuild-plugin-clean';
import copyFilePlugin from 'esbuild-plugin-copy-file';
import esbuild from 'esbuild';
const banner = `
import {createRequire} from 'module';
const require = createRequire(import.meta.url);
`;
esbuild
.build({
entryPoints: ['./src/index.ts'],
platform: 'node',
target: 'node16',
bundle: true,
plugins: [
clean({
patterns: ['./dist/*']
}),
fileloc.filelocPlugin(),
copyFilePlugin({
after: {
'./dist/package.json': './package.json'
}
})
],
loader: {
'.ts': 'ts',
'.js': 'js',
'.cjs': 'js'
},
outdir: 'dist',
external: ['package.json'],
minify: true,
sourcemap: true,
format: 'esm',
banner: {
js: banner
}
})
.catch(error => {
console.error(error.message);
process.exit(1);
});