-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.cjs
More file actions
36 lines (34 loc) · 822 Bytes
/
build.cjs
File metadata and controls
36 lines (34 loc) · 822 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
28
29
30
31
32
33
34
35
36
const path = require('path');
const esbuild = require('esbuild');
const replace = require('replace-in-file');
const { dtsPlugin } = require('esbuild-plugin-d.ts');
const pkg = require(path.resolve('./package.json'));
const external = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
];
esbuild
.build({
entryPoints: ['src/index.ts'],
platform: 'node',
format: 'cjs',
bundle: true,
minify: false,
sourcemap: false,
target: ['node12'],
outfile: 'build/cjs/index.cjs',
tsconfig: 'tsconfig-cjs.json',
external,
plugins: [
dtsPlugin({
tsconfig: 'tsconfig-cjs.json',
}),
],
})
.then(() => {
replace({
files: 'build/cjs/index.cjs',
from: /__buildVersion__/g,
to: pkg.version,
});
});