How to use the svgo/lib/svgo/plugins function in svgo

To help you get started, we’ve selected a few svgo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jakearchibald / svgomg / src / js / svgo-worker / index.js View on Github external
// 0 almost always breaks images when used on this plugin.
        // Better to allow 0 for everything else, but switch to 1 for this plugin.
        plugin.params.floatPrecision = 1;
      } else {
        plugin.params.floatPrecision = floatPrecision;
      }
    }
  }

  const svg = cloneParsedSvg(parsedSvg);
  let svgData;
  let previousDataLength;

  while (svgData === undefined || svgData.length != previousDataLength) {
    previousDataLength = svgData && svgData.length;
    plugins(svg, {input: 'string'}, optimisedPluginsData);
    svgData = js2svg(svg, {
      indent: '  ',
      pretty: settings.pretty
    }).data;

    yield {
      data: svgData,
      dimensions: getDimensions(svg)
    };
  }
}
github mapbox / svg-to-geojson / src / web-workers / svgo.js View on Github external
svg2js(svg, parsedSvg => {
    if (parsedSvg.error) {
      throw Error(parsed.error);
    }

    const svg = cloneParsedSvg(parsedSvg);

    let cleanSvg;
    plugins(svg, {input: 'string'}, optimisedPluginsData);

    cleanSvg = js2svg(svg, { indent: '  ' }).data;
    self.postMessage(cleanSvg);
  });
});
github wadackel / svg-to-jsx-with-gui / src / svg2jsx / processors / svgoProcessor.js View on Github external
svg2js(value, (svg) => {
      if (svg.error) {
        reject(new Error(normalizeErrorString(svg.error)));
        return;
      }

      plugins(svg, opts);

      const jsx = js2svg(svg, {
        indent: '  ',
        pretty: true,
      }).data;

      resolve(jsx);
    });
  });