aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/utils/build-file.js
diff options
context:
space:
mode:
Diffstat (limited to 'config/webpack/utils/build-file.js')
-rw-r--r--config/webpack/utils/build-file.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/config/webpack/utils/build-file.js b/config/webpack/utils/build-file.js
new file mode 100644
index 0000000..9a0ae66
--- /dev/null
+++ b/config/webpack/utils/build-file.js
@@ -0,0 +1,19 @@
+const crypto = require("crypto");
+
+module.exports.getFileName = (fileName, prefix, justHash = false) => {
+ let hash = crypto
+ .createHash("md5")
+ .update(`${prefix}-${fileName}`)
+ .digest("hex");
+
+ if (production) {
+ return hash;
+ } else {
+ hash = hash.substring(16);
+ if (justHash) {
+ return hash;
+ } else {
+ return `${fileName}-${hash}`;
+ }
+ }
+};