Skip to content

Commit

Permalink
Fix generated variables.less file (#1874)
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya authored Dec 7, 2017
1 parent f7988f1 commit ad72c09
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions packages/node-build-scripts/generate-css-variables
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let variablesScss = VARIABLES_SOURCES.reduce((str, currentFilename) => {
// strip comments, clean up for consumption
variablesScss = stripCssComments(variablesScss);
variablesScss = variablesScss
.replace(" !default", "")
.replace(/\ \!default/g, "")
.replace(/(@import|\/\/).*\n+/g, "")
.replace(/border-shadow\((.+)\)/g, "0 0 0 1px rgba($black, $1)")
.replace(/\n{3,}/g, "\n\n");
Expand All @@ -37,15 +37,8 @@ fs.writeFileSync(`${DIST_DIR}/variables.scss`, variablesScss);

// convert scss to less
const variablesLess = variablesScss
.replace(
/rgba\((\$[\w-]+), ([\d\.]+)\)/g,
(match, color, opacity) => `fade(${color}, ${+opacity * 100}%)`
).replace(
/rgba\((\$[\w-]+), (\$[\w-]+)\)/g,
(match, color, variable) => `fade(${color}, ${variable} * 100%)`
).replace(
/\$/g,
"@"
);
.replace(/rgba\((\$[\w-]+), ([\d\.]+)\)/g, (match, color, opacity) => `fade(${color}, ${+opacity * 100}%)`)
.replace(/rgba\((\$[\w-]+), (\$[\w-]+)\)/g, (match, color, variable) => `fade(${color}, ${variable} * 100%)`)
.replace(/\$/g, "@");

fs.writeFileSync(`${DIST_DIR}/variables.less`, variablesLess);

0 comments on commit ad72c09

Please sign in to comment.