From d178caee5c93ad9ed91dbd082b0f0b5a9b0507aa Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Mon, 27 Mar 2023 21:38:43 +0530 Subject: Refactoring code. Only using hashes for output file names. Using singleton pattern to store the callbacks for observeDOM, and only one MutationObserver. --- config/webpack/utils/file-name-hash.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'config/webpack/utils/file-name-hash.js') 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)}`; +}; -- cgit v1.2.3