Skip to content

Utility to convert SVG code into Vue component definition

License

Notifications You must be signed in to change notification settings

qoala-engineering/svg-to-vue

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

svg-to-vue

Utility to convert SVG code into Vue component definition

Instalation

npm i svg-to-vue vue-template-compiler

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

Usage

const svgToVue = require('svg-to-vue');

const code = `
  <svg width="300" height="200" xmlns="http://www.w3.org/2000/svg">
    <rect width="100%" height="100%" fill="red" />
  </svg>
`;

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

API

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

About

Utility to convert SVG code into Vue component definition

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%