rollup-plugin-svgo

Import & clean svg files and export their content as strings

WTFPL 7 个版本
安装
npm install rollup-plugin-svgo
yarn add rollup-plugin-svgo
pnpm add rollup-plugin-svgo
bun add rollup-plugin-svgo
README

version license

✂️ rollup-plugin-svgo

A rollup plugin to import svg files processed with svgo

SVG files, especially those exported from various editors, usually contain a lot of redundant and useless information. This can include editor metadata, comments, hidden elements, default or non-optimal values and other stuff that can be safely removed or converted without affecting the SVG rendering result.

Usage

npm i -D rollup-plugin-svgo
import svgo from 'rollup-plugin-svgo'

export default {
  plugins: [
    svgo(/* options */)
  ]
}

Options

If you want to skip any svgo processing you can pass

{
  raw: true
}

in options. This will import the svg content as is.

Other options are passed directly to svgo to toggle various svgo plugins. You can find all plugins here: https://github.com/svg/svgo#what-it-can-do

Svgo options are a bit verbose to write, so see the defaults used below for how to do it:

Defaults

{
  plugins: [{
    removeViewBox: false
  }, {
    removeDimensions: true
  }]
}
版本列表
2.0.0-beta.1 2022-03-29
2.0.0 2022-06-03
1.1.0 2019-10-15
1.0.3 2019-06-10
1.0.2 2018-11-10
1.0.1 2018-08-16
1.0.0 2018-08-16