Can't figure out NPM, IMGMIN & SVGO to keep/add SVG viewbox

441 Views Asked by At

I'm quite happy with IMGMIN-CLI to optimise images but it removes the viewbox attribute for my SVG files. I'd also like to add the attribute for the SVG files who don't have it and only have the height / width attributes.

This is the script I run from the package.json

"scripts": {
    ...
    "imgmin": "imagemin --plugin.svgo.removeDimensions=true --plugin.svgo.removeViewbox=false assets/src/img/* --out-dir=assets/dist/img",
    ...
  }

And I would run npm run imgmin

Yet, the plugin options don't have any affect. The SVG files withe viewbox attribute have it removed, and those without don't have it added.

I can't figure out what I'm missing.

Do I need to declare something somewhere else in the package.json ?

0

There are 0 best solutions below