aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/utils/build-file.js
blob: 6d8fc859ae5f665aa3c6ced85ed9ceca261222b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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}`;
		}
	}
};