forked from DeutscheModelUnitedNations/munify-delegator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasksBuild.ts
52 lines (46 loc) · 1.27 KB
/
tasksBuild.ts
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
import { build } from 'tsup';
import { join } from 'node:path';
import { exists, rm, mkdir } from 'node:fs/promises';
import packagejson from './package.json';
const rootDir = import.meta.dirname;
const outDir = join(rootDir, 'tasksOut');
const entrypoint = join(rootDir, 'src', 'tasks', 'index.ts');
const tsconfig = join(rootDir, 'tsconfig.json');
const OPTIONS: Parameters<typeof build>[0] = {
entry: {
tasksMain: entrypoint
},
format: ['esm'],
target: 'node22',
outDir,
globalName: 'tasks',
minify: true,
sourcemap: true,
treeshake: true,
bundle: true,
splitting: true,
tsconfig,
external: [
// ...Object.keys(packagejson.dependencies),
// ...Object.keys(packagejson.peerDependencies),
...Object.keys(packagejson.devDependencies)
]
};
console.info('Starting build tasks...');
console.info(
'Building with following paths:',
JSON.stringify({ clientDir: outDir, main: entrypoint })
);
if (await exists(outDir)) {
console.info('Cleaning outDir...');
await rm(outDir, { recursive: true });
console.info('Cleaned outDir!');
}
console.info('Creating outDir...');
await mkdir(outDir, { recursive: true });
console.info('Created outDir!');
console.info('Building tasks...');
await build(OPTIONS);
console.info('Built tasks!');
console.info('Done!');
process.exit(0);