Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-svg-loader

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-svg-loader

Vite plugin to load SVG files as Vue components

  • 5.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
274K
decreased by-5.8%
Maintainers
1
Weekly downloads
 
Created

What is vite-svg-loader?

vite-svg-loader is a Vite plugin that allows you to import SVG files as Vue components. This can be particularly useful for projects using Vue.js, as it enables you to easily manipulate and style SVGs using Vue's reactivity system.

What are vite-svg-loader's main functionalities?

Import SVG as Vue Component

This feature allows you to import an SVG file and use it as a Vue component. This makes it easy to include and manipulate SVGs within your Vue templates.

import MyIcon from './my-icon.svg';

export default {
  components: {
    MyIcon
  },
  template: '<MyIcon />'
};

Inline SVGs

By appending '?inline' to the import statement, you can import the SVG as an inline string. This can be useful for directly embedding SVGs into your HTML.

import MyIcon from './my-icon.svg?inline';

export default {
  template: '<div v-html="MyIcon" />'
};

SVG Optimization

vite-svg-loader supports SVG optimization using SVGO. You can pass SVGO configuration options to optimize your SVGs during the build process.

import MyIcon from './my-icon.svg';

// vite.config.js
import { defineConfig } from 'vite';
import svgLoader from 'vite-svg-loader';

export default defineConfig({
  plugins: [svgLoader({ svgoConfig: { /* SVGO options */ } })]
});

Other packages similar to vite-svg-loader

Keywords

FAQs

Package last updated on 20 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc