forked from mystiq/hydrogen-web
No need to check if icons are already written
This commit is contained in:
parent
2dd655cd9a
commit
6d724e27e7
2 changed files with 5 additions and 10 deletions
|
@ -56,15 +56,7 @@ function addResolvedVariablesToRootSelector(root, { Rule, Declaration }) {
|
|||
function populateMapWithIcons(map, cssFileLocation) {
|
||||
const location = cssFileLocation.match(/(.+)\/.+\.css/)?.[1];
|
||||
const sharedObject = map.get(location);
|
||||
if (sharedObject?.["icon"]) {
|
||||
/**
|
||||
* This postcss plugin is going to run on all theme variants of a single theme.
|
||||
* But we only really need to populate the map once since theme variants only differ
|
||||
* by the values of the base-variables and we don't care about values here.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
map.set(location, { ...sharedObject, "icon": Object.fromEntries(urlVariables) });
|
||||
sharedObject["icon"] = Object.fromEntries(urlVariables);
|
||||
}
|
||||
|
||||
/* *
|
||||
|
|
|
@ -50,6 +50,7 @@ module.exports.tests = function tests() {
|
|||
},
|
||||
"map is populated with icons": async (assert) => {
|
||||
const compiledVariables = new Map();
|
||||
compiledVariables.set("/foo/bar", { "derived-variables": ["background-color--darker-20", "accent-color--lighter-15"] });
|
||||
const inputCSS = `div {
|
||||
background: no-repeat center/80% url("../img/image.svg?primary=main-color--darker-20");
|
||||
}
|
||||
|
@ -61,7 +62,9 @@ module.exports.tests = function tests() {
|
|||
"icon-url-1": "/home/foo/bar/cool.svg?primary=blue&secondary=green",
|
||||
};
|
||||
await postcss([plugin({compiledVariables})]).process(inputCSS, { from: "/foo/bar/test.css", });
|
||||
assert.deepEqual(expectedObject, compiledVariables.get("/foo/bar")["icon"]);
|
||||
const sharedVariable = compiledVariables.get("/foo/bar");
|
||||
assert.deepEqual(["background-color--darker-20", "accent-color--lighter-15"], sharedVariable["derived-variables"]);
|
||||
assert.deepEqual(expectedObject, sharedVariable["icon"]);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue