2023-06-12 02:01:32 +00:00
|
|
|
import { build } from 'esbuild';
|
|
|
|
|
import { rmSync } from 'fs';
|
2023-06-16 02:01:06 +00:00
|
|
|
import { argv } from 'process';
|
|
|
|
|
|
2023-06-26 15:05:05 +00:00
|
|
|
const isProd = !argv.includes('--dev');
|
|
|
|
|
const buildAll = argv.includes('--build=all');
|
|
|
|
|
const buildBot = argv.includes('--build=bot') | buildAll;
|
|
|
|
|
const buildServer = argv.includes('--build=server') | buildAll;
|
2023-06-12 02:01:32 +00:00
|
|
|
|
|
|
|
|
console.log('Removing dist...');
|
|
|
|
|
rmSync('dist', { recursive: true, force: true });
|
|
|
|
|
|
2023-06-26 15:05:05 +00:00
|
|
|
const commonOptions = {
|
2023-06-12 02:01:32 +00:00
|
|
|
platform: 'node',
|
|
|
|
|
loader: {
|
|
|
|
|
'.node': 'copy',
|
|
|
|
|
'.ttf': 'file',
|
|
|
|
|
},
|
|
|
|
|
|
2023-06-17 18:05:04 +00:00
|
|
|
bundle: true,
|
2023-06-19 17:35:28 +00:00
|
|
|
sourcemap: true,
|
2023-06-12 02:01:32 +00:00
|
|
|
minifyIdentifiers: false, // causes errors
|
2023-06-16 17:41:48 +00:00
|
|
|
minifySyntax: isProd,
|
|
|
|
|
minifyWhitespace: isProd,
|
2023-06-17 18:05:04 +00:00
|
|
|
|
|
|
|
|
logLevel: isProd ? 'info' : 'silent',
|
2023-06-26 15:05:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
console.log('Building...');
|
2023-06-26 17:25:28 +00:00
|
|
|
if (buildBot) {
|
|
|
|
|
build({
|
|
|
|
|
...commonOptions,
|
|
|
|
|
|
|
|
|
|
entryPoints: ['src/bot.ts'],
|
|
|
|
|
outfile: 'dist/bot.cjs',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (buildServer) {
|
|
|
|
|
build({
|
|
|
|
|
...commonOptions,
|
|
|
|
|
|
|
|
|
|
entryPoints: ['src/server.ts'],
|
|
|
|
|
outfile: 'dist/server.cjs',
|
|
|
|
|
});
|
|
|
|
|
}
|