-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.js
45 lines (39 loc) · 1.06 KB
/
build.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
import { build } from 'esbuild';
import browserslistToEsbuild from 'browserslist-to-esbuild';
const inputs = [
{ src: './src/index.js', name: 'basics.vector', target: '' },
{ src: './src/operator.js', name: 'basics.vector.operator' },
{ src: './src/adapter/playcanvas.js', name: 'basics.vector.adapter.playcanvas'}
];
const defaultOptions = {
bundle: true,
minify: true,
sourcemap: true,
treeShaking: true,
target: browserslistToEsbuild(),
outbase: 'src'
};
inputs.forEach((item) => {
build({
...defaultOptions,
entryPoints: [item.src],
format: 'iife',
globalName: item.name,
outdir: './build/iife',
}).catch(() => global.process.exit(1));
build({
...defaultOptions,
entryPoints: [item.src],
format: 'esm',
splitting: true,
outdir: './build/esm/',
outExtension: { '.js': '.mjs' }
}).catch(() => global.process.exit(1));
build({
...defaultOptions,
entryPoints: [item.src],
format: 'cjs',
outdir: './build/cjs/',
outExtension: { '.js': '.cjs' }
}).catch(() => global.process.exit(1));
});