# vue-svg-loader

> Use SVG files as Vue Components

Latest version **0.16.0** (published 2020-02-10) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.16.0 |
| Published | 2020-02-10 |
| First published | 2016-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 645 |
| Author | Damian Stasik |
| Maintainers | visualfanatic |
| Keywords | vue-svg-loader, svg, svgo, loader, webpack, vue |

## Links

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

## Dependencies (2)

- [svg-to-vue](https://npm.io/package/svg-to-vue.md) ^0.7.0
- [loader-utils](https://npm.io/package/loader-utils.md) ^1.2.3

## 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.16.0 (latest) — 2020-02-10
- 0.17.0-beta.2 (beta) — 2020-09-13
- 0.12.0-alpha.1 (next) — 2018-11-25
- 0.17.0-beta.1 — 2020-08-23
- 0.17.0-beta.0 — 2020-08-23
- 0.15.0 — 2019-11-11
- 0.14.0 — 2019-11-06
- 0.13.0 — 2019-11-06
- 0.12.0 — 2019-02-05
- 0.11.0 — 2018-10-11
- 0.10.0 — 2018-09-17
- 0.9.0 — 2018-09-05
- 0.8.0 — 2018-08-21
- 0.7.0 — 2018-08-21
- 0.6.0 — 2018-08-21
- … 6 more at https://npm.io/package/vue-svg-loader/versions

## README

<p align="center"><img src="docs/.vuepress/public/logo.svg?sanitize=true" width="40%"></p>
<h1 align="center">vue-svg-loader</h1>
<p align="center">webpack loader that lets you use SVG files as Vue components</p>
<p align="center">
  <a href="https://vue-svg-loader.js.org">Documentation</a> -
  <a href="https://vue-svg-loader.js.org/faq.html">FAQ</a>
</p>

## Installation
``` bash
npm i -D vue-svg-loader vue-template-compiler

yarn add --dev vue-svg-loader vue-template-compiler
```

## Basic configuration
### webpack
``` js
module.exports = {
  module: {
    rules: [
      {
        test: /\.svg$/,
        use: [
          'babel-loader',
          'vue-svg-loader',
        ],
      },
    ],
  },
};
```
### Vue CLI
``` js
module.exports = {
  chainWebpack: (config) => {
    const svgRule = config.module.rule('svg');

    svgRule.uses.clear();

    svgRule
      .use('babel-loader')
      .loader('babel-loader')
      .end()
      .use('vue-svg-loader')
      .loader('vue-svg-loader');
  },
};
```

### Nuxt.js (1.x / 2.x)
``` js
module.exports = {
  build: {
    extend: (config) => {
      const svgRule = config.module.rules.find(rule => rule.test.test('.svg'));

      svgRule.test = /\.(png|jpe?g|gif|webp)$/;

      config.module.rules.push({
        test: /\.svg$/,
        use: [
          'babel-loader',
          'vue-svg-loader',
        ],
      });
    },
  },
};
```

## Example usage
``` vue
<template>
  <nav>
    <a href="https://github.com/vuejs/vue">
      <VueLogo />
      Vue
    </a>
    <a href="https://github.com/svg/svgo">
      <SVGOLogo />
      SVGO
    </a>
    <a href="https://github.com/webpack/webpack">
      <WebpackLogo />
      webpack
    </a>
  </nav>
</template>
<script>
import VueLogo from './public/vue.svg';
import SVGOLogo from './public/svgo.svg';
import WebpackLogo from './public/webpack.svg';

export default {
  name: 'Example',
  components: {
    VueLogo,
    SVGOLogo,
    WebpackLogo,
  },
};
</script>
```

## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fvisualfanatic%2Fvue-svg-loader.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fvisualfanatic%2Fvue-svg-loader?ref=badge_large)

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