aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/utils/build-file.js
blob: 2ab8d86326716dc10913c971386043ef8b8d5dca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const crypto = require("crypto");

module.exports.getFileName = (fileName, prefix, justHash = false) => {
	let hash = crypto
		.createHash("md5")
		.update(`${prefix}-${fileName}`)
		.digest("hex")
		.substring(16);

	if (production) {
		return hash;
	} else {
		if (justHash) {
			return hash;
		} else {
			return `${fileName}-${hash}`;
		}
	}
};