Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antony/rollup-plugin-svg
SVG Plugin for rollupjs
https://github.com/antony/rollup-plugin-svg
rollup rollup-plugin-svg svg
Last synced: 17 days ago
JSON representation
SVG Plugin for rollupjs
- Host: GitHub
- URL: https://github.com/antony/rollup-plugin-svg
- Owner: antony
- Created: 2017-05-13T21:37:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-11-17T09:49:47.000Z (almost 2 years ago)
- Last Synced: 2024-10-11T12:48:23.688Z (about 1 month ago)
- Topics: rollup, rollup-plugin-svg, svg
- Language: JavaScript
- Size: 107 KB
- Stars: 30
- Watchers: 3
- Forks: 6
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rollup-plugin-svg
Import SVG files as base64, or as Markup
[![CircleCI](https://circleci.com/gh/antony/github-backup.svg?style=shield)](https://circleci.com/gh/antony/rollup-plugin-svg) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
## Installation
```bash
npm i -D rollup-plugin-svg
```## Usage
```js
// rollup.config.js
import svg from 'rollup-plugin-svg'export default {
entry: 'src/input.js',
dest: 'dist/output.js',
plugins: [
svg()
]
}
```You can then use svgs in your bundle thusly:
```js
import logo from './desirable-objects.svg'// Without base64:
document.body.appendChild( logo )// With base64:
```## Options:
### base64
Defaults to false.
Bas64 encoded SVGs will be 33% larger than the size on disk. You should therefore only use this for small images where the convenience of having them available on startup (e.g. rendering immediately to a canvas without co-ordinating asynchronous loading of several images) outweighs the cost.
## Sources
This plugin was built (based on the rollup-plugin-image plugin) because it appears that the two existing suitable plugins:
[rollup-plugin-image](https://github.com/rollup/rollup-plugin-image)
[rollup-plugin-url](https://github.com/rollup/rollup-plugin-url)don't seem to work any more. I wanted a simple solution to provide SVG images to [Vudash](http://www.vudash.com)
## License
MIT