inline-svgo-loader
v4.0.0
Published
use svgo to optimize svg file, transformed as inline string.
Downloads
73
Maintainers
Readme
inline-svgo-loader
Use svgo to optimize svg file, transformed as string or data-uri or file.
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 usefallback
option.fallback
:{ loader: string, options: any }
, see above, default fallback isfile-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
.