24 lines
632 B
TypeScript
24 lines
632 B
TypeScript
import { readdirSync } from "node:fs";
|
|
import path from "path";
|
|
|
|
const paths = [
|
|
'./src/functions/api/door'
|
|
];
|
|
|
|
const functionFiles = paths.map(path => readdirSync(path).map(file => path + "/" + file)).flat();
|
|
|
|
// for hot reload to work, we import all the files we want to build
|
|
const imports = functionFiles.forEach(file => require('./' + path.relative('src', file)));
|
|
|
|
console.log("functions to build:", functionFiles);
|
|
|
|
console.log("Building functions...");
|
|
await Bun.build({
|
|
entrypoints: functionFiles,
|
|
outdir: './build/functions',
|
|
packages: 'external',
|
|
target: 'node',
|
|
root: './src/functions',
|
|
format: 'cjs',
|
|
});
|