svgo

  • Version 3.3.2
  • Published
  • 1.49 MB
  • 7 dependencies
  • MIT license

Install

npm i svgo
yarn add svgo
pnpm add svgo

Overview

Nodejs-based tool for optimizing SVG vector graphics files

Index

Functions

function loadConfig

loadConfig: {
(configFile: string, cwd?: string): Promise<Config>;
(configFile?: null, cwd?: string): Promise<Config>;
};
  • If you write a tool on top of svgo you might need a way to load svgo config.

    You can also specify relative or absolute path and customize current working directory.

function optimize

optimize: (input: string, config?: Config) => Output;
  • The core of SVGO

Type Aliases

type Config

type Config = {
/** Can be used by plugins, for example prefixids */
path?: string;
/** Pass over SVGs multiple times to ensure all optimizations are applied. */
multipass?: boolean;
/** Precision of floating point numbers. Will be passed to each plugin that supports this param. */
floatPrecision?: number;
/**
* Plugins configuration
* ['preset-default'] is default
* Can also specify any builtin plugin
* ['sortAttrs', { name: 'prefixIds', params: { prefix: 'my-prefix' } }]
* Or custom
* [{ name: 'myPlugin', fn: () => ({}) }]
*/
plugins?: PluginConfig[];
/** Options for rendering optimized SVG from AST. */
js2svg?: StringifyOptions;
/** Output as Data URI string. */
datauri?: DataUri;
};

    type CustomPlugin

    type CustomPlugin = {
    name: string;
    fn: PluginFn<void>;
    };

      type Output

      type Output = {
      data: string;
      };

        type PluginConfig

        type PluginConfig =
        | keyof BuiltinsWithOptionalParams
        | {
        [Name in keyof BuiltinsWithOptionalParams]: {
        name: Name;
        params?: BuiltinsWithOptionalParams[Name];
        };
        }[keyof BuiltinsWithOptionalParams]
        | {
        [Name in keyof BuiltinsWithRequiredParams]: {
        name: Name;
        params: BuiltinsWithRequiredParams[Name];
        };
        }[keyof BuiltinsWithRequiredParams]
        | CustomPlugin;

          Package Files (1)

          Dependencies (7)

          Dev Dependencies (17)

          Peer Dependencies (0)

          No peer dependencies.

          Badge

          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/svgo.

          • Markdown
            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/svgo)
          • HTML
            <a href="https://www.jsdocs.io/package/svgo"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>