-
Notifications
You must be signed in to change notification settings - Fork 126
/
build.js
57 lines (50 loc) · 1.24 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
52
53
54
55
56
57
//@ts-check
import { createBuilder, createFxmanifest } from '@overextended/fx-utils';
import { spawn } from 'child_process';
const watch = process.argv.includes('--watch');
function exec(command) {
return new Promise((resolve) => {
const child = spawn(command, { stdio: 'inherit', shell: true });
child.on('exit', (code) => {
resolve(code === 0);
});
});
}
if (!watch) {
const tsc = await exec(`tsc --build ${watch ? '--watch --preserveWatchOutput' : ''} && tsc-alias`);
if (!tsc) process.exit(0);
}
createBuilder(
watch,
{
dropLabels: !watch ? ['DEV'] : undefined,
},
[
{
name: 'server',
options: {
platform: 'node',
target: ['node16'],
format: 'cjs',
entryPoints: [`./server/index.ts`],
},
},
{
name: 'client',
options: {
platform: 'browser',
target: ['es2021'],
format: 'iife',
entryPoints: [`./client/index.ts`],
},
},
],
async (files) => {
await createFxmanifest({
client_scripts: [files.client],
server_scripts: [files.server],
files: ['lib/init.lua', 'lib/client/**.lua', 'locales/*.json', 'common/data/*.json'],
dependencies: ['/server:7290', '/onesync'],
});
}
);