about summary refs log tree commit diff
path: root/config/webpack/rules
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2020-09-01 16:52:37 +0200
committerThibaut Girka <thib@sitedethib.com>2020-09-01 17:02:18 +0200
commit3fefb7909ba55d0c8d82a4bf711aac0668a3a38c (patch)
treeb77f9cb09791fbe92cc3a93d1b08c39ee383c843 /config/webpack/rules
parentd95dd3883e0c7d1626f5e3b88d24af2627a641e2 (diff)
parent79305428a7c2bda311bc9d367a84acc28f569522 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- `config/webpack/shared.js`:
  Upstream has changed how Tesseract.js gets included and dropped a dependency.
  The conflict is caused by glitch-soc having different code due to its
  theming system.
  Ported upstream changes.
- `lib/mastodon/version.rb`:
  Upstream refactor/code style change in a place we replaced upstream's
  repo URL with ours.
  Ported upstram changes, keeping our repo URL.
- `yarn.lock`:
  Upstream dropped dependencies, one of which was textually too close to
  a glitch-soc-specific dependency. Not a real conflict.
Diffstat (limited to 'config/webpack/rules')
-rw-r--r--config/webpack/rules/index.js2
-rw-r--r--config/webpack/rules/node_modules.js5
-rw-r--r--config/webpack/rules/tesseract.js14
3 files changed, 20 insertions, 1 deletions
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]',
+    },
+  },
+};