Gathering detailed insights and metrics for @nuxtjs/svg
Gathering detailed insights and metrics for @nuxtjs/svg
Gathering detailed insights and metrics for @nuxtjs/svg
Gathering detailed insights and metrics for @nuxtjs/svg
npm install @nuxtjs/svg
Typescript
Module System
Node Version
NPM Version
JavaScript (73.76%)
Vue (26.24%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
340 Stars
91 Commits
34 Forks
7 Watchers
6 Branches
41 Contributors
Updated on Jun 06, 2025
Latest Version
0.4.1
Package Id
@nuxtjs/svg@0.4.1
Unpacked Size
10.14 kB
Size
4.03 kB
File Count
5
NPM Version
9.5.1
Node Version
18.16.0
Published on
Sep 11, 2023
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
Super simple svg loading module for Nuxt.js
This package is for loading SVG's into Nuxt.js pages. It 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 using file-loader
file.svg?data
- base64 data url import using url-loader
file.svg?inline
- inline import using vue-svg-loader
file.svg?raw
- raw html import using raw-loader
file.svg?sprite
- SVG sprite using svg-sprite-loader
1npm install --save-dev @nuxtjs/svg
1// nuxt.config.js 2export default { 3 buildModules: ["@nuxtjs/svg"], 4};
And that's it! You don't have to install anything else, you're ready to go.
1// nuxt.config.js 2export default { 3 svg: { 4 vueSvgLoader: { 5 // vue-svg-loader options 6 }, 7 svgSpriteLoader: { 8 // svg-sprite-loader options 9 }, 10 fileLoader: { 11 // file-loader options 12 } 13 } 14};
The usage examples are documented as:
1<!-- Nuxt.js code -->
1<!-- Outputted html -->
file-loader
1<template> 2 <img src="~assets/nuxt.svg" /> 3</template>
1<img src="/_nuxt/9405b9978eb50f73b53ac1326b93f211.svg" />
url-loader
1<template> 2 <img src="~assets/nuxt.svg?data" /> 3</template>
1<img src="data:image/svg+xml;base64,P...2h913j1g18h98hr" />
vue-svg-loader
1<template> 2 <NuxtLogo /> 3</template> 4 5<script> 6 import NuxtLogo from "~/assets/nuxt.svg?inline"; 7 8 export default { 9 components: { NuxtLogo }, 10 }; 11</script>
1<svg xmlns="http://www.w3.org/2000/svg"><path></path></svg>
raw-loader
Load the raw SVG data as HTML using raw-loader
:
1<template> 2 <div v-html="rawNuxtLogo" /> 3</template> 4 5<script> 6 import rawNuxtLogo from "~/assets/nuxt.svg?raw"; 7 8 export default { 9 data() { 10 return { rawNuxtLogo }; 11 }, 12 }; 13</script>
1<div> 2 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 298"> 3 <g fill-rule="nonzero" fill="none"><path></path></g> 4 </svg> 5</div>
svg-sprite-loader
1<template> 2 <svg :viewBox="spriteNuxtLogo.viewBox"> 3 <use :xlink:href="'#' + spriteNuxtLogo.id"></use> 4 </svg> 5</template> 6 7<script> 8 import spriteNuxtLogo from "~/assets/nuxt.svg?sprite"; 9 10 export default { 11 data() { 12 return { spriteNuxtLogo }; 13 }, 14 }; 15</script>
1<svg viewBox="0 0 400 298"> 2 <use xlink:href="#nuxt--sprite"></use> 3</svg>
To dynamically import an SVG, you can use the inline require()
syntax.
1<template> 2 <div v-html="require(`../assets/${name}.svg?raw`)" /> 3</template> 4 5<script> 6 export default { 7 props: { 8 name: { type: String, default: "image" }, 9 }, 10 }; 11</script>
This example uses
raw-loader
.
To render an SVG without wrapper element and the use of v-html
, a combination of dynamic components and ?inline
can be used. See #72 for context.
1<template> 2 <component :is="require(`../assets/${name}.svg?inline`)" /> 3</template> 4 5<script> 6 export default { 7 props: { 8 name: { type: String, default: "image" }, 9 }, 10 }; 11</script>
This example uses
vue-svg-loader
.
In order for this module to work correctly, the default .svg
Nuxt.js webpack rule gets replaced with this handler.
The only difference between this and the handler is that there is no limit
for when file-loader
replaces url-loader
.
So when using the ?data
query, it will always use url-loader
regardless of file size, and when not using either resource query, it will always use file-loader
).
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!
Copyright (c) Sam Holmes
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 7/26 approved changesets -- score normalized to 2
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
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
80 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