![]()
vue-svg-loader
webpack loader that lets you use SVG files as Vue components
Documentation -
FAQ
Installation
npm i -D vue-svg-loader vue-template-compiler
yarn add --dev vue-svg-loader vue-template-compiler
Basic configuration
webpack
module.exports = {
module: {
rules: [
{
test: /\.svg$/,
use: [
'babel-loader',
'vue-svg-loader',
],
},
],
},
};
Vue CLI
module.exports = {
chainWebpack: (config) => {
const svgRule = config.module.rule('svg');
svgRule.uses.clear();
svgRule
.use('babel-loader')
.loader('babel-loader')
.end()
.use('vue-svg-loader')
.loader('vue-svg-loader');
},
};
Nuxt.js (1.x / 2.x)
module.exports = {
build: {
extend: (config) => {
const svgRule = config.module.rules.find(rule => rule.test.test('.svg'));
svgRule.test = /\.(png|jpe?g|gif|webp)$/;
config.module.rules.push({
test: /\.svg$/,
use: [
'babel-loader',
'vue-svg-loader',
],
});
},
},
};
Example usage
Vue
SVGO
webpack
import VueLogo from './public/vue.svg';
import SVGOLogo from './public/svgo.svg';
import WebpackLogo from './public/webpack.svg';
export default {
name: 'Example',
components: {
VueLogo,
SVGOLogo,
WebpackLogo,
},
};
License
![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fvisualfanatic%2Fvue-svg-loader.svg?type=large)
Current Tags
0.17.0-beta.2
...
beta
(3 years ago)
0.16.0
...
latest
(3 years ago)
0.12.0-alpha.1
...
next
(4 years ago)
21 Versions
0.17.0-beta.2
...
3 years ago
0.17.0-beta.1
...
3 years ago
0.17.0-beta.0
...
3 years ago
0.16.0
...
3 years ago
0.15.0
...
3 years ago
0.14.0
...
3 years ago
0.13.0
...
3 years ago
0.12.0
...
4 years ago
0.12.0-alpha.1
...
4 years ago
0.11.0
...
4 years ago
0.10.0
...
5 years ago
0.9.0
...
5 years ago
0.8.0
...
5 years ago
0.7.0
...
5 years ago
0.6.0
...
5 years ago
0.5.0
...
5 years ago
0.4.0
...
5 years ago
0.3.0
...
5 years ago
0.2.0
...
6 years ago
0.1.2
...
6 years ago
0.1.1
...
6 years ago
|