-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbuild.js
51 lines (45 loc) · 1.44 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
45
46
47
48
49
50
51
import { glob } from 'glob';
import esbuild from 'esbuild';
import { execSync } from 'child_process';
async function build(packageDir) {
const files = glob.sync(`${packageDir}/src/**/*.ts*`);
const entryPoints = files.filter((file) => !file.includes('.test.'));
const outDir = `${packageDir}/dist`;
const tsconfig = `${packageDir}/tsconfig.build.json`;
// ----- Generate type declaration files ----- //
try {
execSync(`tsc --emitDeclarationOnly --declaration --outDir ${outDir} --project ${tsconfig} --pretty`, {
stdio: 'inherit',
});
console.log(`Built ${outDir}/index.d.ts`);
} catch (error) {
// Process will exit with error code due to execSync failure
console.error('Could not build type declaration files');
process.exit(1);
}
// prettier-ignore
const banner =
`/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Paper Shaders *
* https://github.com/paper-design/shaders *
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
`;
// ----- Build the package ----- //
// esbuild configuration
await esbuild.build({
entryPoints: entryPoints,
outdir: outDir,
banner: {
js: banner,
},
platform: 'browser',
target: 'es2022',
format: 'esm',
treeShaking: true,
sourcemap: true,
minify: false,
});
console.log(`Built ${outDir}/index.js`);
}
build('packages/shaders');
build('packages/shaders-react');