37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
// Copies vendor assets that need to ship in `public/` so they can be fetched
|
|
// at runtime (wasm, etc). Run via npm pre-hooks — see package.json.
|
|
import { copyFile, mkdir, access } from "node:fs/promises";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const ROOT = join(__dirname, "..");
|
|
|
|
const copies = [
|
|
{
|
|
from: "node_modules/occt-import-js/dist/occt-import-js.wasm",
|
|
to: "public/vendor/occt-import-js.wasm",
|
|
},
|
|
];
|
|
|
|
async function main() {
|
|
for (const { from, to } of copies) {
|
|
const src = join(ROOT, from);
|
|
const dest = join(ROOT, to);
|
|
try {
|
|
await access(src);
|
|
} catch {
|
|
console.warn(`[copy-viewer-assets] missing: ${from} — did npm install run?`);
|
|
continue;
|
|
}
|
|
await mkdir(dirname(dest), { recursive: true });
|
|
await copyFile(src, dest);
|
|
console.log(`[copy-viewer-assets] ${from} → ${to}`);
|
|
}
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error("[copy-viewer-assets] failed:", err);
|
|
process.exit(1);
|
|
});
|