Skip to content

A rehype plugin for optimizing inline SVGs using SVGO.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
license-apache
MIT
license-mit
Notifications You must be signed in to change notification settings

TomerAberbach/rehype-svgo

Repository files navigation

rehype-svgo

A rehype plugin for optimizing inline SVGs using SVGO.

Install

$ npm i rehype-svgo

Usage

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

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.

License

MIT © Tomer Aberbach
Apache 2.0 © Google

About

A rehype plugin for optimizing inline SVGs using SVGO.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
license-apache
MIT
license-mit

Stars

Watchers

Forks

Sponsor this project