airbnb / babel-plugin-inline-react-svg

A babel plugin that optimizes and inlines SVGs for your React Components.
MIT License
473 stars 91 forks source link

Enable svgo removeXMLNS plugin by default #9

Open lencioni opened 7 years ago

lencioni commented 7 years ago

This plugin removes the xmlns attribute from the top-level svg element, which is safe for inline SVGs, which is how all SVGs transformed by this plugin will end up being used. I think it makes sense to enable this plugin by default.

https://github.com/svg/svgo/blob/master/plugins/removeXMLNS.js

kesne commented 7 years ago

While it's safe, I think I'd prefer no-plugins by default, and allow people to opt-in to plugins they want.

lencioni commented 7 years ago

How come? svgo has a lot of plugins enabled by default, and this proposal simply extends that to also include a plugin that is guaranteed to always be applicable in this situation.

kesne commented 7 years ago

I just personally prefer having it be a cleaner zero-opinion pass-through to SVGO.

kesne commented 7 years ago

I've changed my mind on this, I think having sane defaults included in the plugin would be great.

emartini commented 7 years ago

Sounds great!, I've added manually all the svgo default plugins and my .babelrc looks more like a svgo config file

lencioni commented 7 years ago

@emartini can you share your configuration here?

emartini commented 7 years ago
["inline-react-svg", {
      "svgo": {
        "plugins": [
          { "cleanupAttrs": true },
          { "removeDoctype": true },
          { "removeXMLProcInst": true },
          { "removeComments": true },
          { "removeMetadata": true },
          { "removeDesc": true },
          { "removeUselessDefs": true },
          { "removeEditorsNSData": true },
          { "removeEmptyAttrs": true },
          { "removeHiddenElems": true },
          { "removeEmptyText": true },
          { "removeEmptyContainers": true },
          { "cleanupEnableBackground": true },
          { "minifyStyles": true },
          { "convertStyleToAttrs": true },
          { "convertColors": true },
          { "convertPathData": true },
          { "convertTransform": true },
          { "removeUnknownsAndDefaults": true },
          { "removeNonInheritableGroupAttrs": true },
          { "removeUselessStrokeAndFill": true },
          { "removeUnusedNS": true },
          { "cleanupIDs": true },
          { "cleanupNumericValues": true },
          { "cleanupListOfValues": true },
          { "moveElemsAttrsToGroup": true },
          { "moveGroupAttrsToElems": true },
          { "collapseGroups": true },
          { "mergePaths": true },
          { "convertShapeToPath": true },
          { "removeXMLNS": true },
        ]
      }
    }]

The only non default option is removeXMLNS