Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/damianstasik/svg-to-vue

Utility to convert SVG code into Vue component definition
https://github.com/damianstasik/svg-to-vue

javascript nodejs svg vue

Last synced: 7 days ago
JSON representation

Utility to convert SVG code into Vue component definition

Awesome Lists containing this project

README

        

svg-to-vue


Utility to convert SVG code into Vue component definition

## Instalation
``` bash
npm i svg-to-vue vue-template-compiler

yarn add svg-to-vue vue-template-compiler
```

## Usage
``` js
const svgToVue = require('svg-to-vue');

const code = `



`;

// Promise
svgToVue(code)
.then((component) => {
// `component` contains Vue component definition
console.log(component);
});

// Async/await
const component = await svgToVue(code);

// `component` contains Vue component definition
console.log(component);
```

## API
``` js
svgToVue(code, {
svgoConfig: {
plugins: [
{
prefixIds: true,
},
],
},
svgoPath: 'some/path/to.svg',
});
```

| Name | Type | Default value | Description |
| - | - | - | - |
| `svgoConfig` | `Object`/`Boolean` | `{}` | Configuration object passed to SVGO or `false` to disable optimization |
| `svgoPath` | `String` | `null` | Path to SVG file which is used by SVGO `prefixIds` plugin to generate unique IDs |