Skip to content

Latest commit

 

History

History
43 lines (36 loc) · 1.51 KB

README.md

File metadata and controls

43 lines (36 loc) · 1.51 KB

inline-svgo-loader

Use svgo to optimize svg file, transformed as string or data-uri or file.

npm version Build Status

Options

  • svgo: SVGO.Options, configuration passed to svgo, see https://github.com/svg/svgo. (ps: datauri will be ignored.)
  • limit: number, when optimized svg file size is larger than limit, will use fallback option.
  • fallback: { loader: string, options: any }, see above, default fallback is file-loader.

Usage

npm install inline-svgo-loader --save-dev
{
  module: {
    rules: [
      {
        test: /\.(svg)(\?.*)?$/,
        loader: 'inline-svgo-loader'
        options: {
          svgo: {},
          limit: 4 * 1024,
          fallback: {
            loader: 'file-loader',
            options: { name: '[name].svg' }
          }
        }
      }
    ]
  }
}

support data:image/svg+xml,

Just append datauri query param to svg file path to support data url(data:image/svg+xml,%3csvg..., Not base64).

eg: in css background-image: url('assets/some.svg?datauri').

This loader will ignore datauri in option svgo.