# vite-plugin-vue-svg-reactive-loader

> Vite 2.x plugin, loads SVG files as Vue components, and automatically adds the viewBox attribute to the svg, so that the svg can be adaptively zoomed.

Latest version **0.0.3** (published 2021-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-vue-svg-reactive-loader
pnpm add vite-plugin-vue-svg-reactive-loader
yarn add vite-plugin-vue-svg-reactive-loader
bun add vite-plugin-vue-svg-reactive-loader
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2021-05-20 |
| First published | 2021-05-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | LiuWenXing |
| Maintainers | liuwenxing |
| Keywords | vite-plugin, vite-plugin-vue, svg-loader |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-vue-svg-reactive-loader
- Repository: https://github.com/LiuWenXing1996/vite-plugin-vue-svg-reactive-loader
- Homepage: https://github.com/LiuWenXing1996/vite-plugin-vue-svg-reactive-loader#readme
- Issues: https://github.com/LiuWenXing1996/vite-plugin-vue-svg-reactive-loader/issues
- npm.io page: https://npm.io/package/vite-plugin-vue-svg-reactive-loader

## Dependencies (1)

- [postsvg](https://npm.io/package/postsvg.md) ^2.2.7

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2021-05-20
- 0.0.2 — 2021-05-20
- 0.0.1 — 2021-05-20

## README

English | [简体中文](./README.zh-CN.md) 

---

**:blush: based on [vite-svg-loader](https://github.com/jpkleemans/vite-svg-loader).**

---

# vite-plugin-vue-svg-reactive-loader
Vite 2.x plugin, loads SVG files as Vue components, and automatically adds the [`viewBox`](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox) attribute to the svg, so that the svg can be adaptively zoomed.

<a href="https://www.npmjs.com/package/vite-plugin-vue-svg-reactive-loader" target="_blank"><img src="https://img.shields.io/npm/v/vite-plugin-vue-svg-reactive-loader?style=flat-square" alt="Version"></a>
<a href="https://www.npmjs.com/package/vite-plugin-vue-svg-reactive-loader" target="_blank"><img src="https://img.shields.io/npm/dw/vite-plugin-vue-svg-reactive-loader?style=flat-square" alt="Downloads"></a>
<a href="https://www.npmjs.com/package/vite-plugin-vue-svg-reactive-loader" target="_blank"><img src="https://img.shields.io/npm/l/vite-plugin-vue-svg-reactive-loader?style=flat-square" alt="License"></a>

```html
<template>
  <MyIcon class="my-icon"/>
</template>

<script setup>
import MyIcon from './my-icon.svg'
</script>

<style scoped>
.my-icon {
    height: 14px;
    width: 14px;
    fill: aqua;
}
</style>
```

### Install
```bash
npm install vite-plugin-vue-svg-reactive-loader --save-dev
```

### Setup

#### `vite.config.js`
```js
import svgReactiveLoader from "vite-plugin-vue-svg-reactive-loader"

export default {
  plugins: [vue(), svgReactiveLoader()],
}
```

### Use with TypeScript
If you use the loader in a Typescript project, you might get warnings like `Type 'string' is not assignable to type 'Component'`.
To fix this you'll need to add the following type definitions to your compiler options:

#### `tsconfig.json`
```json
{
  "compilerOptions": {
    "types": ["vite-plugin-vue-svg-reactive-loader",, "vite/client"]
  }
}
```

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