Installations
npm install vue-cli-plugin-svg
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
14.17.1
NPM Version
6.14.13
Score
34.1
Supply Chain
48.5
Quality
63.9
Maintenance
25
Vulnerability
95.1
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
sam3d
Download Statistics
Total Downloads
500,767
Last Day
158
Last Week
677
Last Month
2,983
Last Year
40,078
GitHub Statistics
MIT License
29 Stars
26 Commits
9 Forks
2 Watchers
6 Branches
2 Contributors
Updated on Nov 21, 2024
Bundle Size
70.97 kB
Minified
24.85 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.2.1
Package Id
vue-cli-plugin-svg@0.2.1
Unpacked Size
9.19 kB
Size
3.93 kB
File Count
6
NPM Version
6.14.13
Node Version
14.17.1
Total Downloads
Cumulative downloads
Total Downloads
500,767
Last Day
29.5%
158
Compared to previous day
Last Week
-1.7%
677
Compared to previous week
Last Month
32.3%
2,983
Compared to previous month
Last Year
-51.1%
40,078
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
1
vue-svg

Super simple svg loading module for Vue.js
(actual npm package is vue-cli-plugin-svg)
Introduction
vue-svg
allows you to import .svg
files in multiple ways depending on the resource query you provide. Currently, this allows you to do the following:
file.svg
- normal import usingfile-loader
file.svg?data
- base64 data url import usingurl-loader
file.svg?inline
- inline import usingvue-svg-loader
file.svg?sprite
- import usingsvg-sprite-loader
(alpha implementation)
Installation
Using the new Vue CLI 3, it's as simple as navigating to your project and running:
1$ vue add svg
That's it! You're ready to go!
Usage
The usage examples are documented as:
1<!-- Vue.js code -->
1<!-- Outputted html -->
Standard external import
Import normally as an external resource using file-loader
1<template> 2 <img src="@/assets/vue-logo.svg" /> 3</template>
1<img src="/img/vue-logo.938241fe.svg" />
Inline base64 url
Inline as a URL (no external requests) using url-loader
1<template> 2 <img src="@/assets/vue-logo.svg?data" /> 3</template>
1<img src="data:image/svg+xml;base64,P...2h913j1g18h98hr" />
Inline svg element
Inline as an actual svg element using vue-svg-loader
1<template> 2 <VueLogo /> 3</template> 4 5<script> 6 import VueLogo from "@/assets/vue-logo.svg?inline"; 7 8 export default { 9 components: { 10 VueLogo 11 } 12 }; 13</script>
1<svg xmlns="http://www.w3.org/2000/svg"><path></path></svg>
Sprite import
1<template> 2 <svg><use xlink:href="#vue-logo"></use></svg> 3</template> 4 5<script> 6 import "@/assets/vue-logo.svg?sprite"; 7</script>
1<!-- Coming shortly -->
Configuration
You can provide options to all of the loaders used in using the vue.config.js
pluginOptions
field:
1// vue.config.js 2 3module.exports = { 4 pluginOptions: { 5 svg: { 6 inline: {}, // Pass options to vue-svg-loader 7 data: {}, // Pass options to url-loader 8 sprite: {}, // Pass options to svg-sprite-loader 9 external: {} // Pass options to file-loader 10 } 11 } 12};
You can provide as many options as you like, or nothing at all. You don't have to configure options, it will use some standard defaults.
You can also customise the resource queries for each type that doesn't get passed as a loader options (other than external
, which doesn't use a resourceQuery):
1// vue.config.js 2 3module.exports = { 4 pluginOptions: { 5 svg: { 6 // You can change this 7 inline: { resourceQuery: /inline/ } 8 } 9 } 10};
Standard defaults
By default, file-loader
will inherit the standard configuration from vue-cli
so that behaves exactly the same.
vue-svg-loader
by default will not use svgo
. This is because it can cause more problems than it solves generally, though this can be easily re-enabled. Check the vue-svg-loader
documentation for more info.
Contributing
As this loader attempts to abstract webpack configuration from the process and make it easier to use multiple svg loaders, any contributions that add more svg loader methods to the configuration will be accepted wholeheartedly!
Also I'll be actively maintaining this project so if you'd rather just make a request for a loader or a feature; I'd be happy to take a look and see what I can do myself :)

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
Found 1/24 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 3 are checked with a SAST tool
Reason
18 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-pfq8-rq6v-vf5m
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
Score
1.7
/10
Last Scanned on 2025-02-03
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