rollup-plugin-svg-to-symbol
A rollup plugin JUST to transform SVG files to symobl strings, then you can freely handle them.
Webpack version: fjc0k/svg-to-symbol-loader
Install
# Yarn yarn add rollup-plugin-svg-to-symbol -D # npm npm i rollup-plugin-svg-to-symbol -D
Usage
// rollup.config.jsconst svgToSymbol = moduleexports = plugins:
// sprite.js '<svg><defs>' add close '</defs></svg>'
The default export just likes:
..... .....
Options
- extractId
- Type:
({ name }) => id
- Default:
({ filePath, name }) => name
- Desc: Use the function to custom symbol id. The
name
is the SVG filename without the extension. e.g.
- Type:
// rollup.config.js
// the add likes:// <symbol id="icon-add">...</symbol>