about summary refs log tree commit diff
path: root/config/webpack/shared.js
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2022-02-13 22:15:26 -0600
committerStarfall <us@starfall.systems>2022-02-13 22:15:26 -0600
commitc0341f06be5310a00b85a5d48fa80891d47c6710 (patch)
tree907ef7f787f8bd446a6d9be1448a8bcff74e5a08 /config/webpack/shared.js
parent169688aa9f2a69ac3d36332c833e9cad43b5f7a5 (diff)
parent6f78c66fe01921a4e7e01aa6e2386a5fce7f3afd (diff)
Merge remote-tracking branch 'glitch/main'
Not at all sure where the admin UI is going to display English language
names now but OK.
Diffstat (limited to 'config/webpack/shared.js')
-rw-r--r--config/webpack/shared.js59
1 files changed, 30 insertions, 29 deletions
diff --git a/config/webpack/shared.js b/config/webpack/shared.js
index ce08ac206..c2a108a89 100644
--- a/config/webpack/shared.js
+++ b/config/webpack/shared.js
@@ -10,38 +10,39 @@ const rules = require('./rules');
 const localePacks = require('./generateLocalePacks');
 
 function reducePacks (data, into = {}) {
-  if (!data.pack) {
-    return into;
-  }
-  Object.keys(data.pack).reduce((map, entry) => {
+  if (!data.pack) return into;
+
+  for (const entry in data.pack) {
     const pack = data.pack[entry];
-    if (!pack) {
-      return map;
+    if (!pack) continue;
+
+    let packFiles = [];
+    if (typeof pack === 'string')
+      packFiles = [pack];
+    else if (Array.isArray(pack))
+      packFiles = pack;
+    else
+      packFiles = [pack.filename];
+
+    if (packFiles) {
+      into[data.name ? `flavours/${data.name}/${entry}` : `core/${entry}`] = packFiles.map(packFile => resolve(data.pack_directory, packFile));
     }
-    const packFile = typeof pack === 'string' ? pack : pack.filename;
-    if (packFile) {
-      map[data.name ? `flavours/${data.name}/${entry}` : `core/${entry}`] = resolve(data.pack_directory, packFile);
+  }
+
+  if (!data.name) return into;
+
+  for (const skinName in data.skin) {
+    const skin = data.skin[skinName];
+    if (!skin) continue;
+
+    for (const entry in skin) {
+      const packFile = skin[entry];
+      if (!packFile) continue;
+
+      into[`skins/${data.name}/${skinName}/${entry}`] = resolve(packFile);
     }
-    return map;
-  }, into);
-  if (data.name) {
-    Object.keys(data.skin).reduce((map, entry) => {
-      const skin = data.skin[entry];
-      const skinName = entry;
-      if (!skin) {
-        return map;
-      }
-      Object.keys(skin).reduce((map, entry) => {
-        const packFile = skin[entry];
-        if (!packFile) {
-          return map;
-        }
-        map[`skins/${data.name}/${skinName}/${entry}`] = resolve(packFile);
-        return map;
-      }, into);
-      return map;
-    }, into);
   }
+
   return into;
 }
 
@@ -49,7 +50,7 @@ const entries = Object.assign(
   { locales: resolve('app', 'javascript', 'locales') },
   localePacks,
   reducePacks(core),
-  Object.keys(flavours).reduce((map, entry) => reducePacks(flavours[entry], map), {})
+  Object.values(flavours).reduce((map, data) => reducePacks(data, map), {})
 );