mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01: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 { build } from 'esbuild';
|
||||||
import { readdir } from 'fs/promises';
|
import { cp, readdir, rm } from 'fs/promises';
|
||||||
|
|
||||||
const root = '../bot';
|
const srcRoot = '../bot';
|
||||||
const workers = await readdir(`${root}/src/workers`);
|
const distRoot = '../../dist/bot';
|
||||||
|
const modulesRoot = '../../node_modules';
|
||||||
|
const workers = await readdir(`${srcRoot}/src/workers`);
|
||||||
|
|
||||||
|
await rm(distRoot, { recursive: true, force: true });
|
||||||
|
|
||||||
build({
|
build({
|
||||||
entryPoints: [
|
entryPoints: [
|
||||||
`${root}/src/main.ts`,
|
`${srcRoot}/src/main.ts`,
|
||||||
...workers.map((worker) => `${root}/src/workers/${worker}`),
|
...workers.map((worker) => `${srcRoot}/src/workers/${worker}`),
|
||||||
],
|
],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
outdir: '../../dist/bot',
|
outdir: '../../dist/bot',
|
||||||
@@ -15,8 +19,25 @@ build({
|
|||||||
format: 'esm',
|
format: 'esm',
|
||||||
loader: {
|
loader: {
|
||||||
'.ttf': 'file',
|
'.ttf': 'file',
|
||||||
'.node': 'file',
|
'.node': 'empty',
|
||||||
},
|
},
|
||||||
minify: true,
|
minify: true,
|
||||||
sourcemap: 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