Skip to content

Instantly share code, notes, and snippets.

@magdairis
Created May 5, 2019 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magdairis/8f2634e1f3df78da7f4d3c4a5088fd5f to your computer and use it in GitHub Desktop.
Save magdairis/8f2634e1f3df78da7f4d3c4a5088fd5f to your computer and use it in GitHub Desktop.
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