aboutsummaryrefslogtreecommitdiff
path: root/gulpfile.js
diff options
context:
space:
mode:
authorcodecalm <codecalm@gmail.com>2020-03-02 16:42:02 +0100
committercodecalm <codecalm@gmail.com>2020-03-02 16:42:02 +0100
commit605ac9c6b9ee69292080b618a2cb0e39062130de (patch)
tree5541ce4479d576de56dc2d347042a6b6c9536282 /gulpfile.js
parentnew icons (diff)
downloadtabler-icons-605ac9c6b9ee69292080b618a2cb0e39062130de.tar.xz
icons optimize
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/gulpfile.js b/gulpfile.js
index beb3969..c5939f7 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -51,16 +51,22 @@ gulp.task('icons-sprite', function (cb) {
});
});
-gulp.task('optimize', function(){
- glob("_site/icons/*.svg", {}, function (er, files) {
+gulp.task('optimize', function(cb){
+ glob("_icons/*.svg", {}, function (er, files) {
files.forEach(function (file, i) {
let svgFile = fs.readFileSync(file),
svgFileContent = svgFile.toString();
svgFileContent = svgFileContent
- .replace(/><\/(polyline|line|rect|circle)>/, '/>')
+ .replace(/><\/(polyline|line|rect|circle|path)>/g, '/>')
+ .replace(/rx="([^"]+)"\s+ry="\1"/g, 'rx="$1"')
+ .replace(/\s?\/>/g, ' />')
+ .replace(/\n\s*<(line|circle|path|polyline)/g, "\n <$1")
+ .replace(/polyline points="([0-9.]+)\s([0-9.]+)\s([0-9.]+)\s([0-9.]+)"/g, 'line x1="$1" y1="$2" x2="$3" y2="$4"')
.replace(/\n\n+/g, "\n");
+
+ console.log('file', file);
fs.writeFileSync(file, svgFileContent);
});