rehype-svgo
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

rehype-svgo

A rehype plugin for optimizing inline SVGs using SVGO.

Install

$ npm i rehype-svgo

Usage

import rehypeParse from 'rehype-parse'
import rehypeSvgo from 'rehype-svgo'
import rehypeStringify from 'rehype-stringify'
import { read } from 'to-vfile'
import { unified } from 'unified'

const file = await unified()
  .use(rehypeParse)
  .use(rehypeSvgo, {
    // https://github.com/svg/svgo#configuration
    svgoConfig: {
      multipass: true,
      plugins: [`preset-default`],
    },
  })
  .use(rehypeStringify)
  .process(await read(`index.html`))

console.log(String(file))

Visit unified's documentation for how to use plugins and svgo's documentation for its configuration options.

Contributing

Stars are always welcome!

For bugs and feature requests, please create an issue.

For pull requests, please read the contributing guidelines.

License

Apache License 2.0

This is not an official Google product.

Package Sidebar

Install

npm i rehype-svgo

Weekly Downloads

11

Version

1.1.2

License

Apache-2.0

Unpacked Size

16.5 kB

Total Files

5

Last publish

Collaborators

  • tomeraberbach