kunkunsh-kunkun-ext-video-p.../scripts/build-template-ext.ts
Huakun Shen 54d6e3519c
init
2025-01-18 04:03:05 -05:00

37 lines
857 B
TypeScript

import { watch } from 'fs';
import { join } from 'path';
import { refreshTemplateWorkerExtension } from '@kksh/api/dev';
import { $ } from 'bun';
const entrypoints = ['./template-ext-src/video-info.ts'];
async function build() {
try {
// for (const entrypoint of entrypoints) {
// await $`bun build --minify --target=browser --outdir=./dist ${entrypoint}`;
// }
await Bun.build({
entrypoints,
target: 'browser',
outdir: './dist',
minify: false
});
if (Bun.argv.includes('dev')) {
await refreshTemplateWorkerExtension();
}
} catch (error) {
console.error(error);
}
}
const srcDir = join(import.meta.dir, '..', 'template-ext-src');
await build();
if (Bun.argv.includes('dev')) {
console.log(`Watching ${srcDir} for changes...`);
watch(srcDir, { recursive: true }, async (event, filename) => {
await build();
});
}