mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
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)
80 lines
1.8 KiB
JavaScript
80 lines
1.8 KiB
JavaScript
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
import terser from "@rollup/plugin-terser";
|
|
import { copy } from "fs-extra";
|
|
|
|
const copyPDFJS = () => ({
|
|
name: "copy-pdfjs",
|
|
async writeBundle() {
|
|
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(
|
|
"node_modules/pdfjs-dist/build/pdf.worker.mjs",
|
|
"vendor/pdfjs/pdf.worker.mjs",
|
|
);
|
|
await copy(
|
|
"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: {
|
|
dir: "vendor/",
|
|
format: "esm",
|
|
},
|
|
plugins: [nodeResolve(), terser()],
|
|
},
|
|
{
|
|
input: "rollup/zip.js",
|
|
output: {
|
|
dir: "vendor/",
|
|
format: "esm",
|
|
},
|
|
plugins: [
|
|
nodeResolve(),
|
|
terser(),
|
|
copyPDFJS(),
|
|
copyOpenCV(),
|
|
copyTensorFlow(),
|
|
copyCocoSsd(),
|
|
],
|
|
},
|
|
];
|