Created
May 5, 2019 10:48
-
-
Save magdairis/8f2634e1f3df78da7f4d3c4a5088fd5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const itemsJson = require('./items.json'); | |
const FS = require('fs'); | |
const PATH = require('path') | |
const SVGO = require('svgo'); | |
const svgo = new SVGO(); | |
let out = itemsJson.map((itemJson) => { | |
let imagePath = itemJson["imagePath"] | |
delete itemJson.imagePath; | |
let svgoFunc = (data) => { | |
itemJson.data = { | |
svg: data.data | |
} | |
}; | |
let fileData = FS.readFileSync(imagePath); | |
svgo.optimize(fileData).then(svgoFunc); | |
return itemJson; | |
}); | |
console.log(out); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment