-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
34 lines (32 loc) · 740 Bytes
/
build.js
File metadata and controls
34 lines (32 loc) · 740 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
const { build } = require('esbuild');
const pkg = require('./package.json');
const modulesToBuild = [
{
file: pkg.module,
format: 'esm'
},
{
file: pkg.main,
format: 'cjs'
}
];
Promise.all(modulesToBuild.map(mod=>build({
entryPoints: [pkg.source],
format: mod.format,
outfile: mod.file,
tsconfig: './tsconfig.build.json',
minify: true,
bundle: true,
logLevel: 'info',
sourcemap: true,
external: ['react', 'react-dom'],
pure:['console.log'],
minifySyntax: true,
}).then(()=>console.log('`%s` built successfully',mod.file))))
.then(() => {
console.log('all modules built successfully');
})
.catch((errors) => {
console.warn('one or more module builds failed', errors);
process.exit(1);
});