rollup-plugin-svg-icons
Version:
Bundles all svg icons from the speciefed folder to the single spritesheet svg file
63 lines (48 loc) • 1.31 kB
Markdown
Bundles all svg icons from the speciefed folder to the single spritesheet svg file.
```bash
npm i -D rollup-plugin-svg-icons
```
```javascript
/* rollup.config.js */
import svgicons from 'rollup-plugin-svg-icons'
export default {
...
plugins: [
svgicons({
// folder with svg-icons
inputFolder: 'src/icons', // it is default value
// path for the sprite file
output: 'dist/bundle.svg', // it is default value
// output file minification
minify: true, // default value is 'false'
// by default svgo is disabled, to turn it on - pass config object (or just empty object)
svgo: { /* config */ },
})
...
]
...
}
```
Use href `bundle.svg
```html
<style>
.inline-svg-icon{
display: inline-block;
fill: currentColor;
width: 24px;
height: 24px;
vertical-align: middle;
}
</style>
<svg class="inline-svg-icon">
<use xlink:href="bundle.svg#iconid"></use>
</svg>
```
Some ideas were peeped from [vladshcherbin](https://github.com/vladshcherbin/rollup-plugin-svg-sprite)
MIT