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

export const 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}`;
		}
	}
};