Source code
Revision control
Copy as Markdown
Other Tools
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
// eslint-disable-next-line import/no-unresolved
import { usesReferences, getReferences } from "style-dictionary/utils";
export const replaceReferences = (value, tokens) => {
let updatedValue = value.toString();
if (usesReferences(value)) {
getReferences(value, tokens).forEach(reference => {
updatedValue = updatedValue.replace(
`{${reference.path.join(".")}}`,
`var(--${reference.name.replace("-base", "")})`
);
});
}
return updatedValue;
};