-
Notifications
You must be signed in to change notification settings - Fork 2
/
esbuild.js
53 lines (48 loc) · 1.25 KB
/
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
46
47
48
49
50
51
52
53
const { build } = require('esbuild');
const pkg = require('./package.json');
const DEV = process.argv.includes('--dev');
(async ()=>{
try{
// ES-module
await build({
entryPoints: ['./src/index.js'],
platform: 'node',
format: "esm",
outfile: pkg.module,
minify: !DEV,
bundle: true,
});
//Node-module
await build({
entryPoints: ['./src/index.js'],
platform: 'node',
format: "cjs",
outfile: pkg.main,
minify: !DEV,
bundle: true,
});
//Bin
await build({
entryPoints: ['./src/bin.js'],
platform: 'node',
format: "cjs",
outfile: pkg.bin.derver,
minify: !DEV,
bundle: true,
external: [pkg.main]
});
//Rollup plugin
await build({
entryPoints: ['./src/plugins/rollup.js'],
platform: 'node',
format: "cjs",
outfile: pkg.exports['./rollup-plugin'],
minify: !DEV,
bundle: true,
external: ['.']
});
}catch(err){
console.log(err);
process.exit(1);
}
})();