ben-eb/gulp-svgmin

Updating extendDefaultPlugins per SVGO warning

djphan opened this issue ยท 8 comments

I ran gulp svgmin and got the following warning. It looks like gulp-svgmin is using ^2.3.1 which is grabbing 2.4.0 which introduced this new warning per release tag: https://github.com/svg/svgo/releases/tag/v2.4.0

If I have some time I can try to make a PR to update the new preset-default config that svgo wants but doing a fresh install and run of the task should output this warning. But if someone gets to this we should update the version to be more explicitly 2.4.0+ with the new config

"extendDefaultPlugins" utility is deprecated. Use "preset-default" plugin with overrides instead. For example: { name: 'preset-default', params: { overrides: { // customize plugin options convertShapeToPath: { convertArcs: true }, // disable plugins convertPathData: false } } }

Created a fork to temporarily fix this, probably not the right approach: https://github.com/DenisLanz/gulp-svgmin. I just went with the svgo config to override the default plugins:

  {
      name: 'preset-default',
      params: {
        overrides:  {
          anotherBuiltinPlugin: false,
        },
      },
    },

and just replaced config.plugins = extendDefaultPlugins( plugins ) with config.plugins = plugins;. Would like to see a proper fix too though. ๐Ÿ™‚

This is an issue for my team as well. Could we get some timeline for when this would be addressed/fixed? Thanks.

Just an update. I'm working on the fork. The above solution/workaround isn't quite right as we'll need to change how the gulp-svgmin inputs map to the plugin array. Before svggo expected a list of objects for plugins like so:

[
  { name: 'removeDoctype', active: false },
  { name: 'removeXMLProcInst', active: true },
  { name: 'removeComments', active: true },
  { name: 'removeMetadata', active: true },
  { name: 'removeXMLNS', active: false },
  { name: 'removeEditorsNSData', active: true },
  { name: 'cleanupAttrs', active: true },
  { name: 'mergeStyles', active: true },
  { name: 'inlineStyles', active: true },
  { name: 'minifyStyles', active: true },
  { name: 'convertStyleToAttrs', active: false },
  { name: 'cleanupIDs', active: true },
  { name: 'prefixIds', active: false },
  { name: 'removeRasterImages', active: false },
  { name: 'removeUselessDefs', active: true },
  { name: 'cleanupNumericValues', active: true },
  { name: 'cleanupListOfValues', active: false },
  { name: 'convertColors', active: true },
  { name: 'removeUnknownsAndDefaults', active: true },
  { name: 'removeNonInheritableGroupAttrs', active: true },
  { name: 'removeUselessStrokeAndFill', active: true },
  { name: 'removeViewBox', active: true },
  { name: 'cleanupEnableBackground', active: true },
  { name: 'removeHiddenElems', active: true },
  { name: 'removeEmptyText', active: true },
  { name: 'convertShapeToPath', active: true },
  { name: 'convertEllipseToCircle', active: true },
  { name: 'moveElemsAttrsToGroup', active: true },
  { name: 'moveGroupAttrsToElems', active: true },
  { name: 'collapseGroups', active: true },
  { name: 'convertPathData', active: true },
  { name: 'convertTransform', active: true },
  { name: 'removeEmptyAttrs', active: true },
  { name: 'removeEmptyContainers', active: true },
  { name: 'mergePaths', active: true },
  { name: 'removeUnusedNS', active: true },
  { name: 'sortAttrs', active: false },
  { name: 'sortDefsChildren', active: true },
  { name: 'removeTitle', active: true },
  { name: 'removeDesc', active: true },
  { name: 'removeDimensions', active: false },
  { name: 'removeAttrs', active: false },
  { name: 'removeAttributesBySelector', active: false },
  { name: 'removeElementsByAttr', active: false },
  { name: 'addClassesToSVGElement', active: false },
  { name: 'removeStyleElement', active: false },
  { name: 'removeScriptElement', active: false },
  { name: 'addAttributesToSVGElement', active: false },
  { name: 'removeOffCanvasPaths', active: false },
  { name: 'reusePaths', active: false }
]

Now for built ins it needs to be like so

 [
            {
                name: 'preset-default',
                params: {overrides: {removeDoctype: false}},
            },
 ]

This format mapping might mean some changes to how the gulp plugin inputs work? But I'm testing how my changes are and cross checking the tests. All of the new formats is documented in the svgo docs here: https://github.com/svg/svgo#configuration

I created #124

I noticed that some changes were made but I'm still having the warning. I'm missing something?

The changes were just merged into master and not updated yet to a cut version. Unless you're pulling master a tagged release is still being determined by the maintainers.

Same issue. Any workaround yet?

rejas commented

Just released v4.1.0. Enjoy!