Skip to content

Commit

Permalink
Merge pull request #54 from msand/patch-2
Browse files Browse the repository at this point in the history
Configure svgo to inline styles with >=1 matches
  • Loading branch information
kristerkari authored Nov 15, 2019
2 parents 79e109b + e5f3734 commit 9fc5f1b
Show file tree
Hide file tree
Showing 3 changed files with 921 additions and 687 deletions.
15 changes: 14 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ function fixRenderingBugs(svgrOutput) {
return xmlnsSvgToXmlns(xlinkHrefToHref(svgrOutput));
}

var defaultsvgrConfig = {
native: true,
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx'],
svgoConfig: {
plugins: [
{
inlineStyles: {
onlyMatchedOnce: false,
},
},
],
},
};

module.exports.transform = function(src, filename, options) {
if (typeof src === "object") {
// handle RN >= 0.46
Expand All @@ -52,7 +66,6 @@ module.exports.transform = function(src, filename, options) {

if (filename.endsWith(".svg") || filename.endsWith(".svgx")) {
var config = resolveConfig.sync(resolveConfigDir(filename));
var defaultsvgrConfig = { native: true };
var svgrConfig = config
? Object.assign({}, defaultsvgrConfig, config)
: defaultsvgrConfig;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"dependencies": {
"@svgr/core": "^4.1.0",
"@svgr/plugin-svgo": "^4.3.1",
"path-dirname": "^1.0.2",
"semver": "^5.6.0"
},
Expand Down
Loading

0 comments on commit 9fc5f1b

Please sign in to comment.