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
3,336 10
Install
npm install vue-svg-sprite-loader
Latest Version:1.2.1
License:MIT
Last Updated:Nov 29, 2018
Links: GitHub  ·  npm
Maintainer: monoguerin

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.

Installation

npm install --save-dev vue-svg-sprite-loader

Configuration

// webpack.config.js
{
  test: /\.svg$/,
  loader: 'vue-svg-sprite-loader',
  options: {
    // Removes svg title, default is false when not passing any options
    removeTitle: true
  }
}

Example code

<template>
  <div id="my-component">
    <h1>Be aware! <alert-icon></alert-icon></h1>
    <span>Hey next to this text should be an heart icon <heart-icon></heart-icon></span>
  </div>
</template>

<script>
import HeartIcon from './assets/iconsSprite.svg?love';
// render svg with a custom title
import AlertIcon from './assets/iconsSprite.svg?alert&title=some-custom-text';

export default {
  name: 'my-component',
  components: {
    'heart-icon': HeartIcon,
    'alert-icon': AlertIcon
  }
};
</script>

The idea behind this was inspired by vue-svg-loader.

Related Packages

@svgv/webpack

Webpack loader to transform SVGs into Vue components.

1,578 4
vue-svg-inline-loader

Webpack loader used for inline replacement of SVG images with actual content of...

591,560 123
vue-svg-inline-loader-corejs3

Webpack loader used for inline replacement of SVG images with actual content of...

964 0
vue-svg-loader

Use SVG files as Vue Components

3,476,564 645
@nuxtjs/markdownit-loader

Webpack loader to translate markdown to HTML using markdownit.

325,518 11

Version History

Version Released License
1.2.1 MIT
1.2.0 MIT
1.1.0 MIT
1.0.0 MIT