{"action":"created","issue":{"url":"https://api.github.com/repos/svg/svgo/issues/204","labels_url":"https://api.github.com/repos/svg/svgo/issues/204/labels{/name}","comments_url":"https://api.github.com/repos/svg/svgo/issues/204/comments","events_url":"https://api.github.com/repos/svg/svgo/issues/204/events","html_url":"https://github.com/svg/svgo/issues/204","id":31382041,"number":204,"title":"mergePaths should run prior to convertPathData","user":{"login":"izwerg","id":7271996,"avatar_url":"https://avatars.githubusercontent.com/u/7271996?v=3","gravatar_id":"","url":"https://api.github.com/users/izwerg","html_url":"https://github.com/izwerg","followers_url":"https://api.github.com/users/izwerg/followers","following_url":"https://api.github.com/users/izwerg/following{/other_user}","gists_url":"https://api.github.com/users/izwerg/gists{/gist_id}","starred_url":"https://api.github.com/users/izwerg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/izwerg/subscriptions","organizations_url":"https://api.github.com/users/izwerg/orgs","repos_url":"https://api.github.com/users/izwerg/repos","events_url":"https://api.github.com/users/izwerg/events{/privacy}","received_events_url":"https://api.github.com/users/izwerg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-04-12T12:20:05Z","updated_at":"2015-02-25T21:30:36Z","closed_at":null,"body":"I use *svgo* through *grunt-svgmin* and have the following piece of config:\r\n```javascript\r\nsvgmin: {\r\n\toptions: {\r\n\t\tplugins: [{\r\n\t\t\ttransformsWithOnePath: { width: 100, height: 100 }\r\n\t\t}]\r\n\t},\r\n\tdist: { files: [{ /* ... */ }] }\r\n},\r\n```\r\n\r\nSo, it uses the default *svgo* configuration, except enabling *transformsWithOnePath*.\r\nEverything works fine with source SVG files containing one path only. However, if there more than one path in source SVG:\r\n```xml\r\n<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\r\n\t width=\"32px\" height=\"32px\" viewBox=\"0 0 32 32\" enable-background=\"new 0 0 32 32\" xml:space=\"preserve\">\r\n<g>\r\n\t<path d=\"M25,9.9c-1.6,0-2.9-1.301-2.9-2.9S23.4,4.1,25,4.1s2.9,1.301,2.9,2.9S26.6,9.9,25,9.9z M25,6.1\r\n\t\tc-0.496,0-0.9,0.404-0.9,0.9s0.404,0.9,0.9,0.9s0.9-0.404,0.9-0.9S25.496,6.1,25,6.1z\"/>\r\n</g>\r\n<g>\r\n\t<path d=\"M14.25,31.075c-0.573,0-1.126-0.237-1.557-0.668l-11.1-11.101c-0.888-0.888-0.888-2.226,0-3.113\r\n\t\tL16.193,1.593C16.885,0.9,17.912,0.9,19,0.9h9.5c1.458,0,2.6,1.142,2.6,2.6c0,6.454,0,8.706-0.107,9.6H31l0.004,0.326\r\n\t\tc0.014,0.781,0.031,1.753-0.697,2.481l-14.5,14.5C15.376,30.838,14.823,31.075,14.25,31.075z M19,2.9c-0.488,0-1.227,0-1.406,0.119\r\n\t\tL3.007,17.607c-0.109,0.109-0.109,0.176,0,0.285l11.1,11.101c0.103,0.104,0.184,0.104,0.286,0l14.5-14.5\r\n\t\tc0.128-0.128,0.119-0.629,0.111-1.032L29,12.688l0.033-0.034C29.076,11.481,29.1,7.28,29.1,3.5c0-0.348-0.252-0.6-0.6-0.6H19z\"/>\r\n</g>\r\n</svg>\r\n```\r\nThe resulting SVG loses all paths other than the first:\r\n```xml\r\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"100\" height=\"100\" viewBox=\"0 0 32 32\"><path d=\"M78.125 146.181c-5 0-9.063-4.066-9.063-9.063s4.063-9.063 9.063-9.063 9.063 4.066 9.063 9.063-4.063 9.063-9.063 9.063zm0-11.875c-1.55 0-2.813 1.263-2.813 2.813s1.263 2.813 2.813 2.813 2.813-1.263 2.813-2.813-1.263-2.813-2.813-2.813z\"/></svg>\r\n```\r\nIf I disable *transformsWithOnePath*, all the paths in the resulting SVG are OK and successfully merged with *mergePaths*:\r\n```xml\r\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" viewBox=\"0 0 32 32\"><path d=\"M25 9.9c-1.6 0-2.9-1.301-2.9-2.9s1.3-2.9 2.9-2.9 2.9 1.301 2.9 2.9-1.3 2.9-2.9 2.9zm0-3.8c-.496 0-.9.404-.9.9s.404.9.9.9.9-.404.9-.9-.404-.9-.9-.9zM14.25 31.075c-.573 0-1.126-.237-1.557-.668l-11.1-11.101c-.888-.888-.888-2.226 0-3.113l14.6-14.6c.692-.693 1.719-.693 2.807-.693h9.5c1.458 0 2.6 1.142 2.6 2.6 0 6.454 0 8.706-.107 9.6h.007l.004.326c.014.781.031 1.753-.697 2.481l-14.5 14.5c-.431.431-.984.668-1.557.668zm4.75-28.175c-.488 0-1.227 0-1.406.119l-14.587 14.588c-.109.109-.109.176 0 .285l11.1 11.101c.103.104.184.104.286 0l14.5-14.5c.128-.128.119-.629.111-1.032l-.004-.773.033-.034c.043-1.173.067-5.374.067-9.154 0-.348-.252-.6-.6-.6h-9.5z\"/></svg>\r\n```\r\nSo the issue is that *transformsWithOnePath* loses paths even if they merged by *mergePaths*. After some debugging, I found the reason.\r\n\r\n*transformsWithOnePath* uses JS-path data converted by *path2js* in *convertPathData*. But *convertPathData* runs before *mergePaths*, so *path2js* converts the first path only and all other paths are lost.\r\n\r\nThe solution is to move *mergePaths* before *convertPathData* in *.svgo.yml*:\r\n```\r\n  - mergePaths\r\n  - convertPathData\r\n```\r\n\r\nThe resulting SVG:\r\n```xml\r\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"100\" height=\"100\" viewBox=\"0 0 32 32\"><path d=\"M78.125 30.938c-5 0-9.063-4.066-9.063-9.063s4.063-9.063 9.063-9.063 9.063 4.066 9.063 9.063-4.063 9.063-9.063 9.063zm0-11.875c-1.55 0-2.813 1.263-2.813 2.813s1.263 2.813 2.813 2.813 2.813-1.263 2.813-2.813-1.263-2.813-2.813-2.813zm-33.594 78.047c-1.791 0-3.519-.741-4.866-2.087l-34.688-34.691c-2.775-2.775-2.775-6.956 0-9.728l45.625-45.625c2.162-2.166 5.372-2.166 8.772-2.166l29.688 0c4.556 0 8.125 3.569 8.125 8.125 0 20.169 0 27.206-.334 30l.022 0l.013 1.019c.044 2.441.097 5.478-2.178 7.753l-45.313 45.313c-1.347 1.347-3.075 2.087-4.866 2.087zm14.844-88.047c-1.525 0-3.834 0-4.394.372l-45.584 45.587c-.341.341-.341.55 0 .891l34.688 34.691c.322.325.575.325.894 0l45.313-45.313c.4-.4.372-1.966.347-3.225l-.013-2.416.103-.106c.134-3.666.209-16.794.209-28.606 0-1.087-.787-1.875-1.875-1.875l-29.688 0z\"/></svg>\r\n```\r\n\r\nPlease review this simple fix."},"comment":{"url":"https://api.github.com/repos/svg/svgo/issues/comments/76064473","html_url":"https://github.com/svg/svgo/issues/204#issuecomment-76064473","issue_url":"https://api.github.com/repos/svg/svgo/issues/204","id":76064473,"user":{"login":"GreLI","id":1467392,"avatar_url":"https://avatars.githubusercontent.com/u/1467392?v=3","gravatar_id":"","url":"https://api.github.com/users/GreLI","html_url":"https://github.com/GreLI","followers_url":"https://api.github.com/users/GreLI/followers","following_url":"https://api.github.com/users/GreLI/following{/other_user}","gists_url":"https://api.github.com/users/GreLI/gists{/gist_id}","starred_url":"https://api.github.com/users/GreLI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GreLI/subscriptions","organizations_url":"https://api.github.com/users/GreLI/orgs","repos_url":"https://api.github.com/users/GreLI/repos","events_url":"https://api.github.com/users/GreLI/events{/privacy}","received_events_url":"https://api.github.com/users/GreLI/received_events","type":"User","site_admin":false},"created_at":"2015-02-25T21:30:36Z","updated_at":"2015-02-25T21:30:36Z","body":"There is one important feature—convertPathData applies transformations to paths. So, if paths have different transformation normally they wouldn't be merged, but after applying transformations, merging becomes possible."}}