Gathering detailed insights and metrics for vue-svg-inline-loader
Gathering detailed insights and metrics for vue-svg-inline-loader
Gathering detailed insights and metrics for vue-svg-inline-loader
Gathering detailed insights and metrics for vue-svg-inline-loader
vue-svg-sprite-loader
Webpack loader that takes a sprite svg and return a Vue component with the svg inline as template that can be imported
inline-vue-svg-loader
a loader for webpack to inline svg
vue-svg-inline-loader-corejs3
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
vue-loader-svg-inliner
Webpack Loader to add simple inline svg support to vue.js single file component
npm install vue-svg-inline-loader
Typescript
Module System
Node Version
NPM Version
69.3
Supply Chain
96.3
Quality
73.6
Maintenance
50
Vulnerability
98.6
License
JavaScript (100%)
Total Downloads
2,912,679
Last Day
1,200
Last Week
5,053
Last Month
21,292
Last Year
344,527
124 Stars
207 Commits
18 Forks
3 Watching
2 Branches
6 Contributors
Minified
Minified + Gzipped
Latest Version
2.1.5
Package Id
vue-svg-inline-loader@2.1.5
Unpacked Size
28.38 kB
Size
9.11 kB
File Count
7
NPM Version
8.13.1
Node Version
16.15.1
Cumulative downloads
Total Downloads
Last day
23.2%
1,200
Compared to previous day
Last week
-19.3%
5,053
Compared to previous week
Last month
-6.6%
21,292
Compared to previous month
Last year
-35%
344,527
Compared to previous year
3
1
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
Loader parses only HTML template format.
Loader has built-in SVGO support for SVG optimization.
Sprite option works only with Vue Single File Component approach.
Vue 3 projects created via Vue CLI aren't built on top of Webpack, they use Vite (which is build on top of Rollup) instead. In this case, this loader won't work. Please take a look at vue-svg-inline-plugin, which works similar to this loader.
true
value as alias for default configurationnull
or false
value for disabling SVG optimization1$ npm install vue-svg-inline-loader --save-dev
1$ yarn add vue-svg-inline-loader --dev
With webpack - webpack.config.js (recommended):
1// webpack 2 3module.exports = { 4 module: { 5 rules: [ 6 { 7 test: /\.vue$/, 8 use: [ 9 { 10 loader: "vue-loader", 11 options: { /* ... */ } 12 }, 13 { 14 loader: "vue-svg-inline-loader", 15 options: { /* ... */ } 16 } 17 ] 18 } 19 ] 20 } 21};
With vue-cli - vue.config.js:
With gridsome - gridsome.config.js:
With quasar - quasar.conf.js:
1// vue-cli, gridsome, quasar 2 3module.exports = { 4 chainWebpack: config => { 5 config.module 6 .rule("vue") 7 .use("vue-svg-inline-loader") 8 .loader("vue-svg-inline-loader") 9 .options({ /* ... */ }); 10 } 11};
With nuxt - nuxt.config.js:
1// nuxt 2 3module.exports = { 4 buildModules: [ 5 [ "vue-svg-inline-loader/nuxt", { /* options */ } ] 6 ], 7 // or 8 buildModules: [ "vue-svg-inline-loader/nuxt" ], 9 vueSvgInlineLoader: { 10 /* options */ 11 } 12};
With quasar - quasar.conf.js:
1// quasar 2 3module.exports = { 4 build: { 5 extendWebpack(config) { 6 const vueRule = config.module.rules.find(({ test }) => test.toString() === /\.vue$/.toString()); 7 vueRule.use.push({ 8 loader: "vue-svg-inline-loader", 9 options: { /* ... */ } 10 }); 11 } 12 } 13};
With laravel-mix - webpack.mix.js:
1// laravel-mix 2 3const mix = require("laravel-mix"); 4 5mix.override(config => { 6 config.module.rules.push({ 7 test: /\.vue$/, 8 use: [{ 9 loader: "vue-svg-inline-loader", 10 options: { /* ... */ } 11 }] 12 }) 13});
Basic inline SVG usage with svg-inline
keyword directive:
1<img svg-inline class="icon" src="./images/example.svg" alt="example" />
Which replaces into:
1<svg xmlns="http://www.w3.org/2000/svg" viewBox="..." svg-inline role="presentation" focusable="false" tabindex="-1" class="icon"> 2 <path d="..."></path> 3</svg>
Basic inline SVG sprite usage with svg-sprite
keyword directive:
1<img svg-inline svg-sprite class="icon" src="./images/example.svg" alt="example" />
Which replaces into:
1<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="..." svg-inline svg-sprite role="presentation" focusable="false" tabindex="-1" class="icon"> 2 <use xlink:href="#svg-sprite-md5hash" href="#svg-sprite-md5hash"></use> 3</svg> 4<!-- ... --> 5<!-- will get injected right before root closing tag in Vue component --> 6<svg xmlns="http://www.w3.org/2000/svg" style="display: none !important;"> 7 <symbol id="svg-sprite-md5hash" xmlns="http://www.w3.org/2000/svg" viewBox="..."> 8 <path d="..."></path> 9 </symbol> 10 <!-- ... --> 11</svg>
Loader won't parse any images with Vue bindings used as src
attribute [more info].
If you need to preserve image tag (e.g. in comments), you can wrap it in hash (#
) or triple backtick (```
) characters.
Default options:
1{ 2 inline: { 3 keyword: "svg-inline", 4 strict: true 5 }, 6 sprite: { 7 keyword: "svg-sprite", 8 strict: true 9 }, 10 addTitle: false, 11 cloneAttributes: ["viewbox"], 12 addAttributes: { 13 role: "presentation", 14 focusable: false, 15 tabindex: -1 16 }, 17 dataAttributes: [], 18 removeAttributes: ["alt", "src"], 19 transformImageAttributesToVueDirectives: true, 20 md5: true, 21 xhtml: false, 22 svgo: true, 23/* value true for svgo option is alias for: 24 svgo: { 25 plugins: [ 26 { 27 removeViewBox: false 28 } 29 ] 30 }, 31*/ 32 verbose: false 33}
Explanation:
inline.keyword:
Defines keyword, which marks images you want to replace with inline SVG. Keyword has to be wrapped with whitespace characters (e.g. space).
In case of some conflicts, you can also use data version of your keyword (e.g. data-keyword
).
inline.strict:
In strict mode loader replaces only images with defined keyword. If strict mode is disabled, loader replaces all images.
sprite.keyword:
Defines keyword, which marks images you want to replace with inline SVG using inline sprites. Keyword has to be wrapped with whitespace characters (e.g. space).
In case of some conflicts, you can also use data version of your keyword (e.g. data-keyword
).
sprite.strict:
In strict mode loader replaces only images with defined keyword. If strict mode is disabled, loader replaces all images.
addTitle:
Transform image alt
attribute into SVG title
tag, if not defined (removed with SVGO by default). This option has no effect while using inline SVG sprites.
cloneAttributes:
Array of attributes which will be cloned into SVG link node while using inline SVG sprites.
addAttributes:
Object of attributes which will be added.
dataAttributes:
Array of attributes which will be renamed to data-attributes.
removeAttributes:
Array of attributes which will be removed.
transformImageAttributesToVueDirectives:
Transforms all non-Vue image tag attributes via Vue v-bind
directive. With this option enabled, Vue will handle merge / replace attributes, that are present on both resources - image tag and SVG tag. This might cause issues, when using Vue bindings on image tag attribute, that is also present on SVG tag (e.g.: class attribute). Please use verbose option for local debugging before submitting new issue.
md5:
Use md5-encoded resource path as ID for inline SVG sprites instead of plaintext. Set it to false
only for development purposes.
xhtml:
In XHTML mode attribute minimization is forbidden. Empty attributes are filled with their names to be XHTML-compliant (e.g. disabled="disabled"
).
svgo:
Pass SVGO configuration object (documentation can be found here) or true
for default configuration. Pass null
or false
to disable SVG optimization.
verbose:
Will print image tag, SVG tag and modified SVG tag (with attributes from image tag) for debugging purposes.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 1/28 approved changesets -- score normalized to 0
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
security policy file not detected
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
Score
Last Scanned on 2025-01-20
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