mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: build bot completely
This commit is contained in:
1 parent
ced3897696
commit
c81f6d08c0
1 file changed
+27
-6
@@ -1,13 +1,17 @@
|
||||
import { build } from 'esbuild';
|
||||
import { readdir } from 'fs/promises';
|
||||
import { cp, readdir, rm } from 'fs/promises';
|
||||
|
||||
const root = '../bot';
|
||||
const workers = await readdir(`${root}/src/workers`);
|
||||
const srcRoot = '../bot';
|
||||
const distRoot = '../../dist/bot';
|
||||
const modulesRoot = '../../node_modules';
|
||||
const workers = await readdir(`${srcRoot}/src/workers`);
|
||||
|
||||
await rm(distRoot, { recursive: true, force: true });
|
||||
|
||||
build({
|
||||
entryPoints: [
|
||||
`${root}/src/main.ts`,
|
||||
...workers.map((worker) => `${root}/src/workers/${worker}`),
|
||||
`${srcRoot}/src/main.ts`,
|
||||
...workers.map((worker) => `${srcRoot}/src/workers/${worker}`),
|
||||
],
|
||||
bundle: true,
|
||||
outdir: '../../dist/bot',
|
||||
@@ -15,8 +19,25 @@ build({
|
||||
format: 'esm',
|
||||
loader: {
|
||||
'.ttf': 'file',
|
||||
'.node': 'file',
|
||||
'.node': 'empty',
|
||||
},
|
||||
minify: true,
|
||||
sourcemap: true,
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
(await readdir(`${modulesRoot}/@resvg`)).map(async (module) => {
|
||||
const files = await readdir(`${modulesRoot}/@resvg/${module}`).then(
|
||||
(files) => files.filter((file) => file.endsWith('.node')),
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
files.map(async (file) => {
|
||||
await cp(
|
||||
`${modulesRoot}/@resvg/${module}/${file}`,
|
||||
`${distRoot}/workers/${file}`,
|
||||
);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
Reference in new issue
Block a user