Build: vendor panel detection dependencies

Update rollup config to copy OpenCV, TensorFlow.js, and COCO-SSD
libraries to vendor directory. These dependencies are used for the
panel detection feature and need to be bundled with the application
instead of loaded from npm packages at runtime.

- Add copyOpenCV() plugin to copy OpenCV.js from node_modules
- Add copyTensorFlow() plugin to copy TensorFlow.js from node_modules
- Add copyCocoSsd() plugin to copy COCO-SSD model from node_modules
- Apply formatting consistency (double quotes for imports)
This commit is contained in:
2026-04-13 18:50:13 -04:00
parent 2a9a11adb3
commit 495d73b717
+72 -25
View File
@@ -1,32 +1,79 @@
import { nodeResolve } from '@rollup/plugin-node-resolve' import { nodeResolve } from "@rollup/plugin-node-resolve";
import terser from '@rollup/plugin-terser' import terser from "@rollup/plugin-terser";
import { copy } from 'fs-extra' import { copy } from "fs-extra";
const copyPDFJS = () => ({ const copyPDFJS = () => ({
name: 'copy-pdfjs', name: "copy-pdfjs",
async writeBundle() { async writeBundle() {
await copy('node_modules/pdfjs-dist/build/pdf.mjs', 'vendor/pdfjs/pdf.mjs') await copy("node_modules/pdfjs-dist/build/pdf.mjs", "vendor/pdfjs/pdf.mjs");
await copy('node_modules/pdfjs-dist/build/pdf.mjs.map', 'vendor/pdfjs/pdf.mjs.map') await copy(
await copy('node_modules/pdfjs-dist/build/pdf.worker.mjs', 'vendor/pdfjs/pdf.worker.mjs') "node_modules/pdfjs-dist/build/pdf.mjs.map",
await copy('node_modules/pdfjs-dist/build/pdf.worker.mjs.map', 'vendor/pdfjs/pdf.worker.mjs.map') "vendor/pdfjs/pdf.mjs.map",
await copy('node_modules/pdfjs-dist/cmaps', 'vendor/pdfjs/cmaps') );
await copy('node_modules/pdfjs-dist/standard_fonts', 'vendor/pdfjs/standard_fonts') await copy(
}, "node_modules/pdfjs-dist/build/pdf.worker.mjs",
}) "vendor/pdfjs/pdf.worker.mjs",
);
export default [{ await copy(
input: 'rollup/fflate.js', "node_modules/pdfjs-dist/build/pdf.worker.mjs.map",
"vendor/pdfjs/pdf.worker.mjs.map",
);
await copy("node_modules/pdfjs-dist/cmaps", "vendor/pdfjs/cmaps");
await copy(
"node_modules/pdfjs-dist/standard_fonts",
"vendor/pdfjs/standard_fonts",
);
},
});
const copyOpenCV = () => ({
name: "copy-opencv",
async writeBundle() {
await copy(
"node_modules/@techstark/opencv-js/dist/opencv.js",
"vendor/opencv/opencv.js",
);
},
});
const copyTensorFlow = () => ({
name: "copy-tensorflow",
async writeBundle() {
await copy(
"node_modules/@tensorflow/tfjs/dist/index.js",
"vendor/tfjs/tf.min.js",
);
},
});
const copyCocoSsd = () => ({
name: "copy-coco-ssd",
async writeBundle() {
await copy(
"node_modules/@tensorflow-models/coco-ssd/dist/coco-ssd.min.js",
"vendor/coco-ssd/coco-ssd.min.js",
);
},
});
export default [
{
input: "rollup/fflate.js",
output: { output: {
dir: 'vendor/', dir: "vendor/",
format: 'esm', format: "esm",
}, },
plugins: [nodeResolve(), terser()], plugins: [nodeResolve(), terser()],
}, },
{ {
input: 'rollup/zip.js', input: "rollup/zip.js",
output: { output: {
dir: 'vendor/', dir: "vendor/",
format: 'esm', format: "esm",
}, },
plugins: [nodeResolve(), terser(), copyPDFJS()], plugins: [
}] nodeResolve(),
terser(),
copyPDFJS(),
copyOpenCV(),
copyTensorFlow(),
copyCocoSsd(),
],
},
];