From cc29dc045d1106cf3fc9154268aec7a839bf9913 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Fri, 17 Jun 2022 16:38:13 +0530 Subject: [PATCH] Move scope down in css-url-processor --- scripts/postcss/css-url-processor.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/postcss/css-url-processor.js b/scripts/postcss/css-url-processor.js index f58818f1..8308e106 100644 --- a/scripts/postcss/css-url-processor.js +++ b/scripts/postcss/css-url-processor.js @@ -16,7 +16,6 @@ limitations under the License. const valueParser = require("postcss-value-parser"); const resolve = require("path").resolve; -let cssPath; function colorsFromURL(url, colorMap) { const params = new URL(`file://${url}`).searchParams; @@ -36,7 +35,7 @@ function colorsFromURL(url, colorMap) { return [primaryColor, secondaryColor]; } -function processURL(decl, replacer, colorMap) { +function processURL(decl, replacer, colorMap, cssPath) { const value = decl.value; const parsed = valueParser(value); parsed.walk(node => { @@ -84,8 +83,8 @@ module.exports = (opts = {}) => { Go through each declaration and if it contains an URL, replace the url with the result of running replacer(url) */ - cssPath = root.source?.input.file.replace(/[^/]*$/, ""); - root.walkDecls(decl => processURL(decl, opts.replacer, colorMap)); + const cssPath = root.source?.input.file.replace(/[^/]*$/, ""); + root.walkDecls(decl => processURL(decl, opts.replacer, colorMap, cssPath)); }, }; };