{"action":"created","issue":{"url":"https://api.github.com/repos/jhamlet/svg-react-loader/issues/40","repository_url":"https://api.github.com/repos/jhamlet/svg-react-loader","labels_url":"https://api.github.com/repos/jhamlet/svg-react-loader/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/jhamlet/svg-react-loader/issues/40/comments","events_url":"https://api.github.com/repos/jhamlet/svg-react-loader/issues/40/events","html_url":"https://github.com/jhamlet/svg-react-loader/issues/40","id":181203600,"number":40,"title":"Cleanup svg","user":{"login":"tiemevanveen","id":1330668,"avatar_url":"https://avatars.githubusercontent.com/u/1330668?v=3","gravatar_id":"","url":"https://api.github.com/users/tiemevanveen","html_url":"https://github.com/tiemevanveen","followers_url":"https://api.github.com/users/tiemevanveen/followers","following_url":"https://api.github.com/users/tiemevanveen/following{/other_user}","gists_url":"https://api.github.com/users/tiemevanveen/gists{/gist_id}","starred_url":"https://api.github.com/users/tiemevanveen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiemevanveen/subscriptions","organizations_url":"https://api.github.com/users/tiemevanveen/orgs","repos_url":"https://api.github.com/users/tiemevanveen/repos","events_url":"https://api.github.com/users/tiemevanveen/events{/privacy}","received_events_url":"https://api.github.com/users/tiemevanveen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-05T16:28:47Z","updated_at":"2016-10-07T12:40:04Z","closed_at":null,"body":"Awesome loader, exactly what I was looking for moving from my old gulp setup :).\r\n\r\nThe only thing I'm still looking for is a way to cleanup the SVG with something like https://github.com/svg/svgo. Do you know if this is currently possible? I could work on a PR if not. Let me know. "},"comment":{"url":"https://api.github.com/repos/jhamlet/svg-react-loader/issues/comments/252241788","html_url":"https://github.com/jhamlet/svg-react-loader/issues/40#issuecomment-252241788","issue_url":"https://api.github.com/repos/jhamlet/svg-react-loader/issues/40","id":252241788,"user":{"login":"tiemevanveen","id":1330668,"avatar_url":"https://avatars.githubusercontent.com/u/1330668?v=3","gravatar_id":"","url":"https://api.github.com/users/tiemevanveen","html_url":"https://github.com/tiemevanveen","followers_url":"https://api.github.com/users/tiemevanveen/followers","following_url":"https://api.github.com/users/tiemevanveen/following{/other_user}","gists_url":"https://api.github.com/users/tiemevanveen/gists{/gist_id}","starred_url":"https://api.github.com/users/tiemevanveen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiemevanveen/subscriptions","organizations_url":"https://api.github.com/users/tiemevanveen/orgs","repos_url":"https://api.github.com/users/tiemevanveen/repos","events_url":"https://api.github.com/users/tiemevanveen/events{/privacy}","received_events_url":"https://api.github.com/users/tiemevanveen/received_events","type":"User","site_admin":false},"created_at":"2016-10-07T12:40:04Z","updated_at":"2016-10-07T12:40:04Z","body":"Okay, my bad. I think I did not look well enough in the output to see that you already do some cleanup. I think I overlooked this because it seems the loader adds some extra stuff as well:\r\n\r\n```svg\r\n<svg version=\"1.1\" id=\"Icons\" xmlns=\"http://www.w3.org/2000/svg\" data-svgreactloader=\"[[&quot;http://www.w3.org/2000/svg&quot;,&quot;xlink&quot;,&quot;http://www.w3.org/1999/xlink&quot;],[&quot;http://www.w3.org/2000/svg&quot;,&quot;space&quot;,&quot;preserve&quot;]]\" x=\"0px\" y=\"0px\" width=\"21px\" height=\"21px\" viewBox=\"0 0 21 21\" enable-background=\"new 0 0 21 21\" xlink=\"http://www.w3.org/1999/xlink\" space=\"preserve\">\r\n\t<path d=\"8 0 1.4.6 1.4 1.4 0 .7-.6 1.4-1.4 1.4zm ... \"></path>\r\n</svg>\r\n```\r\n\r\nIs this supposed to happen?\r\n\r\nI tried ta add svgo btw, which resulted in the folowing output:\r\n\r\n```svg\r\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"21\" height=\"21\" viewBox=\"0 0 21 21\">\r\n\t<path d=\"8 0 1.4.6 1.4 1.4 0 .7-.6 1.4-1.4 1.4zm ... \"></path>\r\n</svg>\r\n```\r\n\r\nI can image even with some sanitising in place, it might be handy to replace that for svgo. Although that means adding another dependency to the project, you do get the benefit of regular patches to svgo (and not having to maintain the sanitise code yourself) plus you could support used defined svgo options (in the webpack config?) so users can benefit from all svgo options. \r\n\r\nHere's the patch I used to add svgo, also see https://github.com/tiemevanveen/svg-react-loader/commit/d893659a253c3388f5a3c0166d1689a9f74ea5b4\r\n\r\n```diff\r\n--- a/index.js\r\n+++ b/index.js\r\n@@ -9,6 +9,8 @@ var assign   = require('lodash/assign');\r\n var keys     = require('lodash/keys');\r\n var partial  = require('lodash/partial');\r\n+var SVGO     = require('svgo');\r\n\r\n function readTemplate (callback, filepath) {\r\n     fs.readFile(filepath, 'utf8', function (error, contents) {\r\n         if (error) {\r\n@@ -20,7 +22,17 @@ function readTemplate (callback, filepath) {\r\n\r\n function parseXml (callback, source) {\r\n     var xmlParser = new xml2js.Parser();\r\n-    xmlParser.parseString(source, callback);\r\n+\r\n+    var svgo = new SVGO();\r\n+    svgo.optimize(source, function(result) {\r\n+        if (result.error) {\r\n+            console.log('SVGO failed', result.error);\r\n+            // fall back on source\r\n+            xmlParser.parseString(source, callback);\r\n+        }else{\r\n+            xmlParser.parseString(result.data, callback);\r\n+        }\r\n+    });\r\n }\r\n```"}}
{"actor":{"display_login":"tiemevanveen"}}