deployment-talks/chat-app/build.ts

42 lines
680 B
TypeScript

import { unlink } from 'node:fs/promises';
const config = {
entrypoints: [ "./frontend/index.js" ],
outdir: "./static/js/",
};
async function fileExists(path: string): Promise<bool> {
const file = Bun.file(path);
return file.exists();
}
async function main() {
const results = await Bun.build({
...config,
verbose: true,
define: {
'Bun.env.APP_URL': `"${Bun.env.APP_URL}"`,
}
});
if (!results.success) {
for (const message of results.logs) {
console.error(message);
}
return false;
}
return true;
}
main()
.then(() => {
process.exit(0)
})
.catch((e) => {
console.error(e);
process.exit(1);
});