What is SVGO and how to use it to not remove the viewBox?

Card Puncher Data Processing

About

Svgo 1) is a svg Minifier written in Javascript

You can use it:

Example: How to not remove the viewBox by default

The following config file disables the removeViewBox option. Why? Because without any viewBox, you will not be able to resize it via CSS.

// Svgo deletes by default the viewbox
// https://github.com/svg/svgo/blob/main/README.md#default-preset
module.exports = {
    plugins: [
        {
            name: 'preset-default',
            params: {
                overrides: {
                    removeViewBox: false
                },
            },
        },
    ],
};
  • We can call the cli with yarn dlx. For instance, with the Boostrap icons.
yarn dlx svgo ..\..\node_modules\bootstrap-icons\icons\filetype-png.svg -o filetype-png.svg





Discover More
Card Puncher Data Processing
List of SVG Editors / Software and Utility

This page lists editors, libraries or GUI software that can manipulate SVG. GUI * ! * From Svg to Code and vice versa: ()...



Share this page:
Follow us:
Task Runner