Adds CSS custom property file to the build script

This will regenerate the CSS file automatically when the build script is run. This way we don’t have to manually maintain lists of variables whenever icons are added or changed.
This commit is contained in:
Dan Leech 2017-02-26 12:31:52 +00:00 committed by GitHub
parent ce95cff89f
commit 030151d134

View File

@ -117,6 +117,7 @@ fs.writeFile("../404.html", htmlOutput, function(err) {
var sass = "// Brand colours from simpleicons.org\n";
var less = "// Brand colours from simpleicons.org\n";
var css = "/* Brand colours from simpleicons.org */\n\n:root {";
var maxNameLength = 0;
for (var i = 0; i < source.icons.length; i++) {
@ -153,8 +154,11 @@ for (var i = 0; i < source.icons.length; i++) {
sass += "\n$color-brand-" + fileName.toLowerCase() + ": " + spacing + "#" + source.icons[i].hex.toUpperCase() + ";";
less += "\n@color-brand-" + fileName.toLowerCase() + ": " + spacing + "#" + source.icons[i].hex.toUpperCase() + ";";
css += "\n --color-brand-" + fileName.toLowerCase() + ": " + spacing + "#" + source.icons[i].hex.toUpperCase() + ";";
}
css += "\n}";
// Generate Sass file with colour variables
fs.writeFile("../colour-variables.scss", sass, function(err) {
if(err) {
@ -170,3 +174,11 @@ fs.writeFile("../colour-variables.less", less, function(err) {
}
console.log(" - brand-colours.less built successfully.");
});
// Generate CSS file with colour variables
fs.writeFile("../colour-variables.css", css, function(err) {
if(err) {
return console.log(err);
}
console.log(" - brand-colours.css build successfully.");
});