1.0.0 • Published 3 years ago

craco-plugin-svg-sprite v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
3 years ago

craco-plugin-svg-sprite

NPM version Downloads License

craco-plugin for creatin SVG sprites.

Motivation: How to use SVG sprites in a project.

prerequisite

You have to learn what SVG sprites.

then,Learn how to use SVGO to compress SVG.

Finally, summarize the application in the project

Three package involved:

Usage

npm install craco-plugin-svg-sprite --save-dev

... or with Yarn

yarn add craco-plugin-svg-sprite -D

Configuration

// craco.config.js   => plugins
const cracoPluginSvgSprite = require("craco-plugin-svg-sprite");

{
    plugin: cracoPluginSvgSprite,
    options: {
        include: "src",                 // required
        compress: true,                 // option
        svgoConfig: {                   // option

        },
        spriteLoaderConfig: {           // option

        },
        svgPrefixName: "icon"           // option
    },
}

configuration parameter:

PropertyDescriptionTypeDefaultOption
includefiles to includestring-required
svgPrefixNamesvg file prefix namestring-option
compressis a svgo usedbooleantrueoption
svgoConfigsvgo-loader configobject-option
spriteLoaderConfigsvg-sprite-loader configobject-option

reference

在 create-react-app 创建的项目中使用 svg-sprite-loader