Skip to content

Instantly share code, notes, and snippets.

@shobhitsharma
Created July 12, 2019 12:03
Show Gist options
  • Save shobhitsharma/306b97f9b572658515daaf12c1b50f99 to your computer and use it in GitHub Desktop.
Save shobhitsharma/306b97f9b572658515daaf12c1b50f99 to your computer and use it in GitHub Desktop.
localIdent.js
function getLocalIdent(context, localIdentName, localName, options) {
const fileName = context.resourcePath
? context.resourcePath.replace(/^.*[\\\/]/, "").replace(".style.scss", "")
: uuid();
return `hua-${fileName}__${localName}`;
}
function uuid() {
var firstPart = (Math.random() * 46656) | 0;
var secondPart = (Math.random() * 46656) | 0;
firstPart = ("000" + firstPart.toString(36)).slice(-3);
secondPart = ("000" + secondPart.toString(36)).slice(-3);
return firstPart + secondPart;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment