Gathering detailed insights and metrics for svg-to-vue-component
Gathering detailed insights and metrics for svg-to-vue-component
Gathering detailed insights and metrics for svg-to-vue-component
Gathering detailed insights and metrics for svg-to-vue-component
svg-to-vue
Utility to convert SVG code into Vue component definition
vue-svg-sprite
Vue.js plugin, component and directive to simply use SVG sprite
vue-simple-svg
A simple Vue.js plugin that allows you to use a component that loads a SVG image as an inline SVG so you can easily control its fill color from the parent component.
vite-plugin-svg-sfc
Convert SVGs to Vue single file component(SFC), support <style> tag
Transform SVG files into Vue SFC (with hot reloading and SVGO support)
npm install svg-to-vue-component
Typescript
Module System
Node Version
NPM Version
JavaScript (95.6%)
Vue (3.76%)
CSS (0.64%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
236 Stars
45 Commits
18 Forks
3 Watchers
3 Branches
6 Contributors
Updated on Dec 21, 2024
Latest Version
0.3.8
Package Id
svg-to-vue-component@0.3.8
Size
4.83 kB
NPM Version
6.5.0
Node Version
11.14.0
Published on
Apr 16, 2019
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
When you import the .svg
file as a Vue component instead of using the URL to the file, you can style it with CSS and add addtional DOM properties or event handlers to the component directly.
The differences between this project and vue-svg-loader are:
vue-loader
.class
and style
attributes on the generated component while we support all DOM props and events.1yarn add svg-to-vue-component --dev
1// webpack.config.js 2module.exports = { 3 module: { 4 rules: [ 5 { 6 test: /\.svg$/, 7 // If you want to import svg in css files 8 // You need to configure another rule to use file-loader for that 9 issuer: /\.(vue|js|ts|svg)$/, 10 use: [ 11 // This loader compiles .svg file to .vue file 12 // So we use `vue-loader` after it 13 'vue-loader', 14 'svg-to-vue-component/loader' 15 ] 16 } 17 ] 18 } 19 // ...other configurations 20}
Then you can import .svg
files directly and use them as Vue components:
1<template> 2 <!-- Dom props and events are all available here --> 3 <CheckIcon width="20px" height="20px" @click="handleClick" /> 4</template> 5 6<script> 7import CheckIcon from './check-icon.svg' 8 9export default { 10 components: { 11 CheckIcon 12 }, 13 14 methods: { 15 handleClick() { 16 console.log('It works!') 17 } 18 } 19} 20</script>
In your vue.config.js
:
1module.exports = { 2 chainWebpack(config) { 3 // Only convert .svg files that are imported by these files as Vue component 4 const FILE_RE = /\.(vue|js|ts|svg)$/ 5 6 // Use vue-cli's default rule for svg in non .vue .js .ts files 7 config.module.rule('svg').issuer(file => !FILE_RE.test(file)) 8 9 // Use our loader to handle svg imported by other files 10 config.module 11 .rule('svg-component') 12 .test(/\.svg$/) 13 .issuer(file => FILE_RE.test(file)) 14 .use('vue') 15 .loader('vue-loader') 16 .end() 17 .use('svg-to-vue-component') 18 .loader('svg-to-vue-component/loader') 19 } 20}
In your poi.config.js
:
1module.exports = { 2 plugins: ['svg-to-vue-component/poi'], 3 4 // Or with options for the webpack loader 5 plugins: [ 6 { 7 resolve: 'svg-to-vue-component/nuxt', 8 options: {} 9 } 10 ] 11}
In your nuxt.config.js
:
1module.exports = { 2 modules: ['svg-to-vue-component/nuxt'], 3 4 // Or with options for the webpack loader 5 modules: [ 6 ['svg-to-vue-component/nuxt', 7 { 8 // ... 9 } 10 ] 11 ] 12}
Pass loader options like this:
1// ... 2{ 3 test: /\.svg$/, 4 use: [ 5 'vue-loader', 6 { 7 loader: 'svg-to-vue-component/loader', 8 options: { 9 // ...Your options here 10 } 11 } 12 ] 13}
Option | Description |
---|---|
svgoConfig | Project-wise configuration for SVGO, if you want file-relative configuration, use the config file instead, supported format: .svgo.{yml,js,json} , see here for an example file. If you want to turn off SVGO entirely, pass false here. |
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
svg-to-vue-component © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).
Website · GitHub @EGOIST · Twitter @_egoistlily
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
170 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More