-
Notifications
You must be signed in to change notification settings - Fork 3
/
esbuild.js
38 lines (34 loc) · 667 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
const { build } = require('esbuild');
const pkg = require('./package.json');
const DEV = process.argv.includes('--dev');
// common to all builds
const common = {
entryPoints: ['./src/index.ts'],
minify: !DEV,
sourcemap: DEV && 'inline',
bundle: true
};
// module specific
const builds = {
// Node module
cjs: {
outfile: pkg.main
},
// ES6 module
esm: {
outfile: pkg.module,
},
// Browser bundle
iife: {
globalName: 'Storxy',
outfile: DEV ? './test/visual/storxy.test.js' : pkg.cdn,
}
};
Object.keys(builds).forEach(key => {
const options = {
...common,
...builds[key],
format: key
};
build(options);
});