aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/utils/file-name-hash.js
blob: 889e9a45b3eb55e8d7a307b187099c37fc498b95 (plain)
1
2
3
4
5
6
7
8
9
10
11
const crypto = require("crypto");

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)}`;
};