# rollup-plugin-svg

> Import SVG images

Latest version **2.0.0** (published 2019-06-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-svg
pnpm add rollup-plugin-svg
yarn add rollup-plugin-svg
bun add rollup-plugin-svg
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-06-22 |
| First published | 2017-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Antony Jones |
| Maintainers | antony |
| Keywords | rollup, modules, images, svg |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-svg
- Repository: https://github.com/antony/rollup-plugin-svg
- Homepage: https://github.com/antony/rollup-plugin-svg#readme
- Issues: https://github.com/antony/rollup-plugin-svg/issues
- npm.io page: https://npm.io/package/rollup-plugin-svg

## Dependencies (1)

- [rollup-pluginutils](https://npm.io/package/rollup-pluginutils.md) ^1.3.1

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2019-06-22
- 1.0.1 — 2017-05-13
- 1.0.0 — 2017-05-13

## 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:
<img src="{logo}" alt="Whatever" />
```

## 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

---
_Source: https://npm.io/package/rollup-plugin-svg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
