Closed adrienWeiss closed 2 years ago
Hello,
I'm trying to add & modify plugins using the svgoConfig in .vue-svgicon.config.js (in vue-cli-plugin-svgicon), and after a while I think I've figure out why it does not work as expected :
svgoConfig
.vue-svgicon.config.js
{ svgoConfig: { plugins: [ { myPlugin1: true }, { myPlugin2: true}] } }
But svgoConfig is merged with svgo defaultConfig using lodash _.merge, which recursively merges arrays see example here https://lodash.com/docs/4.17.15#merge
_.merge
https://github.com/MMF-FE/svgicon/blob/8781ec0a68cf60f89b8d8efeb4e40757f2b1de17/packages/svgicon-gen/src/index.ts#L43
So we endup with a real config that has an incorrect shape
plugins: [ { removeAttrs: {}, myPlugin1: true }, { removeTitle: true, myPlugin2: true }, { inlineStyles: { onlyMatchedOnce: false } }, { minifyStyles: true }, ... ]
I'm not sure what would the best approach be here, but it looks like svgo v2 has the util extendDefaultPlugins for this use case.
svgo updated, from ^1.3.2 to ^2.8.0, please update @yzfe/svgicon-loader@1.2.0, see change log. Override svgo config: https://github.com/svg/svgo#default-preset
Hello,
I'm trying to add & modify plugins using the
svgoConfig
in.vue-svgicon.config.js
(in vue-cli-plugin-svgicon), and after a while I think I've figure out why it does not work as expected :But svgoConfig is merged with svgo defaultConfig using lodash
_.merge
, which recursively merges arrays see example here https://lodash.com/docs/4.17.15#mergehttps://github.com/MMF-FE/svgicon/blob/8781ec0a68cf60f89b8d8efeb4e40757f2b1de17/packages/svgicon-gen/src/index.ts#L43
So we endup with a real config that has an incorrect shape
I'm not sure what would the best approach be here, but it looks like svgo v2 has the util extendDefaultPlugins for this use case.