svg-vue is a Vue 2 component designed to display SVG assets that have been processed and inlined by its companion Laravel Mix plugin, `laravel-mix-svg-vue`. It provides a declarative way to render SVGs within Vue templates, leveraging the build-time optimizations (like SVGO) provided by the Laravel Mix plugin. The current and only stable version is `0.2.0`, published over four years ago, indicating the package is largely abandoned with no ongoing development or maintenance. Its core differentiator was its tight integration into the Laravel Mix build pipeline, which was prevalent in many Laravel-Vue 2 projects, allowing for seamless management and rendering of SVGs without manual inline embedding or complex loading configurations. It does not support Vue 3+ directly and is strongly tied to older build tooling. Alternatives like `vue-inline-svg` or `unplugin-svg-vue-component` offer similar functionality for modern Vue versions and bundlers.
npm install svg-vueVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates global registration of the `svg-vue` component and its usage within a Vue 2 template, including passing an `icon` prop and applying CSS classes. It also shows usage within a loop, emphasizing the importance of the `:key` attribute for dynamic lists.
For Vue 3, consider modern alternatives like `vue-inline-svg` or `unplugin-svg-vue-component` which are designed for the Vue 3 composition API and Vite/Webpack 5 environments.
Ensure `laravel-mix-svg-vue` is installed and properly configured in your `webpack.mix.js` file, specifying the correct `svgPath` where your SVG files reside.
For new projects or existing projects requiring ongoing maintenance, it is strongly recommended to use a currently maintained SVG component solution that supports modern build tools and Vue versions. Migrate to an active alternative.
Always add a unique `:key` attribute when using `v-for`. For example: `<svg-vue :icon="item.icon" :key="item.id"></svg-vue>`.
Ensure you `import SvgVue from 'svg-vue';` and then globally register it with `Vue.component('svg-vue', SvgVue);` before `new Vue({ ... })`, or locally register it within the `components` option of a parent component.Run `npm install svg-vue` or `yarn add svg-vue`. Verify your `node_modules` directory contains `svg-vue` and your bundler configuration (e.g., Webpack/Laravel Mix) correctly resolves node modules.
Install the build-time plugin: `npm install laravel-mix-svg-vue --save-dev` or `yarn add laravel-mix-svg-vue --dev`. Then, ensure it's required and enabled in your `webpack.mix.js` file: `require('laravel-mix-svg-vue');` and `mix.svgVue();`.