craco-plugin-svg-sprite

1.0.0 • Public • Published

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:

Property Description Type Default Option
include files to include string - required
svgPrefixName svg file prefix name string - option
compress is a svgo used boolean true option
svgoConfig svgo-loader config object - option
spriteLoaderConfig svg-sprite-loader config object - option

reference

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

Package Sidebar

Install

npm i craco-plugin-svg-sprite

Weekly Downloads

146

Version

1.0.0

License

ISC

Unpacked Size

7.28 kB

Total Files

9

Last publish

Collaborators

  • condorhero