-
Notifications
You must be signed in to change notification settings - Fork 38
/
esbuild.js
41 lines (34 loc) · 983 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
const esbuild = require('esbuild');
const { existsSync, mkdirSync, writeFileSync} = require('fs');
const {join} = require('path');
const lib = join(process.cwd(), 'lib');
if (!existsSync(lib)) {
mkdirSync(lib);
}
esbuild
.build({
entryPoints: ['src/index.ts'],
outdir: 'lib/esm',
bundle: true,
sourcemap: true,
minify: true,
splitting: true,
format: 'esm',
target: ['esnext'],
external: ['antd','react','dayjs','jalaliday','rc-picker'],
})
.catch(() => process.exit(1));
esbuild
.build({
entryPoints: ['src/index.ts'],
outfile: 'lib/cjs/index.cjs.js',
bundle: true,
sourcemap: true,
minify: true,
platform: 'node',
target: ['node16'],
external: ['antd','react','dayjs','jalaliday','rc-picker'],
})
.catch(() => process.exit(1));
writeFileSync(join(lib, 'index.js'), "export * from './esm/index.js';");
writeFileSync(join(lib, 'index.cjs.js'), "module.exports = require('./cjs/index.cjs.js');");