Installations
npm install svg-module-next
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
16.14.2
NPM Version
8.19.2
Score
42.6
Supply Chain
48.6
Quality
66.4
Maintenance
50
Vulnerability
98.6
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (73.76%)
Vue (26.24%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
nuxt-community
Download Statistics
Total Downloads
290
Last Day
1
Last Week
2
Last Month
14
Last Year
52
GitHub Statistics
MIT License
341 Stars
91 Commits
35 Forks
8 Watchers
6 Branches
41 Contributors
Updated on Jan 11, 2025
Package Meta Information
Latest Version
1.0.1
Package Id
svg-module-next@1.0.1
Unpacked Size
10.13 kB
Size
4.01 kB
File Count
5
NPM Version
8.19.2
Node Version
16.14.2
Total Downloads
Cumulative downloads
Total Downloads
290
Last Day
0%
1
Compared to previous day
Last Week
-60%
2
Compared to previous week
Last Month
0%
14
Compared to previous month
Last Year
-36.6%
52
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
svg-module-next
Super simple svg loading module for Nuxt.js
Introduction
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 usingfile-loader
file.svg?data
- base64 data url import usingurl-loader
file.svg?inline
- inline import usingvue-svg-loader
file.svg?raw
- raw html import usingraw-loader
file.svg?sprite
- SVG sprite usingsvg-sprite-loader
Installation
1npm install --save-dev svg-module-next
1// nuxt.config.js 2export default { 3 buildModules: ["svg-module-next"], 4};
And that's it! You don't have to install anything else, you're ready to go.
Configuration
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};
Usage
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>
Dynamic imports
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
.
Caveats
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
).
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!
License
Copyright (c) Sam Holmes

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
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
- 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
project is not fuzzed
Details
- Warn: no fuzzer integrations found
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 12 are checked with a SAST tool
Reason
77 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-whgm-jr23-g3j9
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-257v-vj4p-3w2h
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-phwq-j96m-2c2q
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2
- Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-pfq8-rq6v-vf5m
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-7r28-3m3f-r2pr
- Warn: Project is vulnerable to: GHSA-r8j5-h5cx-65gg
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- 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-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-vf6r-87q4-2vjf
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94
- Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-662x-fhqg-9p8v
- Warn: Project is vulnerable to: GHSA-394c-5j6w-4xmx
- Warn: Project is vulnerable to: GHSA-78cj-fxph-m83p
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-5j4c-8p2g-v4jx
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
2
/10
Last Scanned on 2025-02-10
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