aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/utils/file-name-hash.js
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-03-27 21:38:43 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-03-27 21:38:43 +0530
commitd178caee5c93ad9ed91dbd082b0f0b5a9b0507aa (patch)
treeccfdf4c6992a86955c80780de0518a2fea10ac39 /config/webpack/utils/file-name-hash.js
parent5955bd821303cffa35263c41286339fb28e7536b (diff)
downloadbanglar-bhumi-utils-d178caee5c93ad9ed91dbd082b0f0b5a9b0507aa.tar.gz
banglar-bhumi-utils-d178caee5c93ad9ed91dbd082b0f0b5a9b0507aa.zip
Refactoring code.
Only using hashes for output file names. Using singleton pattern to store the callbacks for observeDOM, and only one MutationObserver.
Diffstat (limited to 'config/webpack/utils/file-name-hash.js')
-rw-r--r--config/webpack/utils/file-name-hash.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/config/webpack/utils/file-name-hash.js b/config/webpack/utils/file-name-hash.js
index e3988a9..889e9a4 100644
--- a/config/webpack/utils/file-name-hash.js
+++ b/config/webpack/utils/file-name-hash.js
@@ -1,3 +1,11 @@
const crypto = require("crypto");
-module.exports.getFileNameHash = fileName => crypto.createHash("md5").update(fileName).digest("hex").substring(16);
+module.exports.getFileNameHash = (fileName, prefix) => {
+ const finalFileName = `${prefix}-${fileName}`;
+ const hash = crypto
+ .createHash("md5")
+ .update(finalFileName)
+ .digest("hex");
+
+ return production ? hash : `${fileName}-${hash.substring(16)}`;
+};