0

I am using Dianoga for SVGs. I would like to disable removeViewBox. What is the syntax for adding additional arguments to SVGO? Here is what I have (that does not work):

<dianogaOptimizeSvg>
    <!-- Optimize the SVG with SVGO https://github.com/svg/svgo -->
    <processor type="Dianoga.Optimizers.Pipelines.DianogaSvg.SvgoOptimizer, Dianoga">
        <ExePath>/App_Data/Dianoga Tools/SVGO/svgop.exe</ExePath>
        <AdditionalToolArguments>-disable={removeViewBox}</AdditionalToolArguments>
    </processor>
</dianogaOptimizeSvg>

2 Answers 2

1

Unfortunately, SVGOP was built with a preset list of plugins. And it is not possible to change svgop.exe behavior in runtime.

What is possible is to build your own executable using pkg:

//install svgo
npm i svgo
//install pkg
npm install -g pkg
//make your own executable from svgo
//if you don't want to play with passing any parameters using Dianoga, 
//prior this step you can change plugins list of plugins configuration under \node_modules\svgo
npx pkg node_modules/svgo

Or you can try Dianoga 6+ version, where it should be possible to pass configuration to SVG optimizer.

0

Looking at the source code for Dianoga, it appears that the Additional Tool Arguments parameter for SVGO are not wired up. I'll need to make my own version of Dianoga.Optimizers.Pipelines.DianogaSvg.SvgoOptimizer. Luckily it looks like I will be able to swap out my own implementation fairly easily.

2
  • I'll be happy to accept a pull request with this improvement. Aug 30, 2020 at 22:59
  • Once I figure out how to make it work I will gladly submit one. Aug 31, 2020 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.