From 5fc5a9f9f18872cb0f1b54359338b2e189dd2bb1 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 1 Sep 2020 00:26:10 +0200 Subject: Update Tesseract.js (#14708) * [WiP] Update Tesseract.js - Update Tesseract.js to 2.2.1 - Use versioned file names - differentiate two progression states: preparing OCR and detecting picture * Get rid of copy-webpack-plugin --- config/webpack/rules/index.js | 2 ++ config/webpack/rules/node_modules.js | 5 ++++- config/webpack/rules/tesseract.js | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 config/webpack/rules/tesseract.js (limited to 'config/webpack/rules') diff --git a/config/webpack/rules/index.js b/config/webpack/rules/index.js index bbf6b0187..92a384e6d 100644 --- a/config/webpack/rules/index.js +++ b/config/webpack/rules/index.js @@ -1,6 +1,7 @@ const babel = require('./babel'); const css = require('./css'); const file = require('./file'); +const tesseract = require('./tesseract'); const nodeModules = require('./node_modules'); // Webpack loaders are processed in reverse order @@ -8,6 +9,7 @@ const nodeModules = require('./node_modules'); // Lastly, process static files using file loader module.exports = { file, + tesseract, css, nodeModules, babel, diff --git a/config/webpack/rules/node_modules.js b/config/webpack/rules/node_modules.js index 7ed05504b..c084d3a57 100644 --- a/config/webpack/rules/node_modules.js +++ b/config/webpack/rules/node_modules.js @@ -4,7 +4,10 @@ const { settings, env } = require('../configuration'); module.exports = { test: /\.(js|mjs)$/, include: /node_modules/, - exclude: /@babel(?:\/|\\{1,2})runtime/, + exclude: [ + /@babel(?:\/|\\{1,2})runtime/, + /tesseract.js/, + ], use: [ { loader: 'babel-loader', diff --git a/config/webpack/rules/tesseract.js b/config/webpack/rules/tesseract.js new file mode 100644 index 000000000..de647c8d1 --- /dev/null +++ b/config/webpack/rules/tesseract.js @@ -0,0 +1,14 @@ +module.exports = { + test: [ + /tesseract\.js\/dist\/worker\.min\.js$/, + /tesseract\.js\/dist\/worker\.min\.js.map$/, + /tesseract\.js-core\/tesseract-core\.wasm$/, + /tesseract\.js-core\/tesseract-core\.wasm.js$/, + ], + use: { + loader: 'file-loader', + options: { + name: 'ocr/[name]-[hash].[ext]', + }, + }, +}; -- cgit