Replies: 1 comment 1 reply
-
To generate unique names for Here's an example of how you might modify your plugin to use this approach: registerPlugin({
install: function (less, pluginManager, functions) {
functions.add('uniqueName', function (name) {
const randomPart = Math.random().toString(36).substring(2, 10);
const timestampPart = Date.now().toString(36);
return `${name}-${randomPart}-${timestampPart}`;
});
}
}); This method generates a suffix using a random string and the current timestamp, which should be sufficient for most use cases where you need to avoid conflicts with To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
I want to generate unique names for
@keyframes
, because even nested ones just come global after compilation and this could cause conflicts.Since, AFAIK, there is no way to get a current scope as a string (?), I decided to write a plugin for mangling names. It provides the following function:
Maybe, this would work, if compile LESS code on-the-go (in a browser), but a VS extension Web Compiler 2022+ uses something else. Not sure, what it is, Node.JS, maybe, but the environment doesn't implement
crypto
at all.So, I ended up with clumsy
Math.random()
-based suffixes.Is there a better way of avoiding conflicts with
@keyframes
?Beta Was this translation helpful? Give feedback.
All reactions