Bug report: Tesseract worker.min.js copied to wrong path by CopyWebpackPlugin, breaking OCR
Describe the bug
The Optical Character Recognition operation fails at runtime because worker.min.js is copied to the wrong destination path during the webpack build. The CopyWebpackPlugin configuration preserves the dist/ subdirectory from the source, placing the file at assets/tesseract/dist/worker.min.js, but the operation hardcodes the path as assets/tesseract/worker.min.js.
To Reproduce Steps to reproduce the behaviour or a link to the recipe / input used to cause the bug:
- Clone the CyberChef repository
- Run
npm install - Run the webpack build (e.g.
npm run build) - Open CyberChef in a browser and use the Optical Character Recognition operation
- Observe that the operation fails — the Tesseract worker cannot be loaded
Expected behaviour
The OCR operation should load successfully. worker.min.js should be available at assets/tesseract/worker.min.js as expected by OpticalCharacterRecognition.mjs.
Screenshots N/A — runtime failure in the browser console when using the OCR operation.
Root cause
In webpack.config.js, the CopyWebpackPlugin pattern for the Tesseract worker sets context to the package root rather than the dist/ subdirectory:
{
context: "node_modules/tesseract.js/",
from: "dist/worker.min.js",
to: "assets/tesseract"
}
CopyWebpackPlugin preserves the directory structure of from relative to context, so the dist/ prefix is carried into the destination, producing assets/tesseract/dist/worker.min.js.
However, OpticalCharacterRecognition.mjs expects the file at:
const worker = await createWorker("eng", oem, {
workerPath: `${assetDir}tesseract/worker.min.js`,
...
});
Proposed fix
Move context down into the dist/ subdirectory so the file is copied without the extra path segment:
{
context: "node_modules/tesseract.js/dist/",
from: "worker.min.js",
to: "assets/tesseract"
}
Desktop (if relevant, please complete the following information):
- OS: Any
- Browser: Any
- CyberChef version: current
masterbranch
Additional context
The other two Tesseract asset copy patterns (tesseract-core.wasm.js and lang-data) are not affected — their context and from values are already consistent with the paths expected at runtime.
Hi,
I've tested this with the recipe
https://gchq.github.io/CyberChef/#recipe=Generate_Lorem_Ipsum(4,'Paragraphs')Generate_Image('Greyscale',8,64)Image_Brightness_/_Contrast(-1,0)Add_Text_To_Image('ocr%20test','None','None',128,128,32,'Roboto',255,255,255,255)Optical_Character_Recognition(true,'Tesseract/LSTM%20Combined')&oenc=65001
against the current version of CyberChef on Github (as at 9:30UTC on 2026-06-12) and I can't reproduce the problem.
What version of Node, what OS, and what processor family are you using?