aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/loaders
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-02-09 13:50:24 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-02-09 13:50:24 +0530
commit0404234c26f6813025e9eedd9981e1536db28b2a (patch)
tree204e2ca55540e594e4d88eba87191b90794ddaf8 /config/webpack/loaders
parent915947e3e7ab7c1fa07596ab4b13bf6e1cc50b76 (diff)
downloadbanglar-bhumi-utils-0404234c26f6813025e9eedd9981e1536db28b2a.tar.gz
banglar-bhumi-utils-0404234c26f6813025e9eedd9981e1536db28b2a.zip
Combined the scripts with the same runtime into a single file to improve performance
Diffstat (limited to 'config/webpack/loaders')
-rw-r--r--config/webpack/loaders/scoped-loader.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/config/webpack/loaders/scoped-loader.js b/config/webpack/loaders/scoped-loader.js
index 3b68ba6..1be58a4 100644
--- a/config/webpack/loaders/scoped-loader.js
+++ b/config/webpack/loaders/scoped-loader.js
@@ -1,5 +1,18 @@
const path = require("path");
+const scripts = require(path.resolve(process.env.SOURCE_DIR, "scripts.json"));
+
+const getScriptType = scriptName => {
+ for (const scriptType in scripts) {
+ if (scripts[scriptType][scriptName]) {
+ return scriptType;
+ }
+ }
+ return "undefined_script";
+};
+
module.exports = function (source) {
- return `/**\t${path.basename(this.resourcePath)}\t**/\n(() => {\n${source}\n})();`
+ return `/*<--\t${getScriptType(path.basename(this.resourcePath))}\t-->*/
+(() => {\n${source}\n})();
+/*<---->*/`
};