Socket
Socket
Sign inDemoInstall

@kingyue/vite-plugin-vue2-svg

Package Overview
Dependencies
9
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @kingyue/vite-plugin-vue2-svg

Vite plugin to load SVG files as Vue 2 components


Version published
Maintainers
1
Created

Readme

Source

vite-plugin-vue2-svg

Load SVG files as Vue components, for Vue2.x only.

This fork fixs bugs of the unmaintained original repo.

NPM

Install

pnpm add -D @kingyue/vite-plugin-vue2-svg
# or
yarn add -D @kingyue/vite-plugin-vue2-svg
# or
npm install -D @kingyue/vite-plugin-vue2-svg

Usage

// vite.config.ts
import { defineConfig } from "vite";
import createVuePlugin from "@vitejs/plugin-vue2";
import { createSvgPlugin } from "@kingyue/vite-plugin-vue2-svg";

export default defineConfig({
  plugins: [createVuePlugin(), createSvgPlugin()],
});
<!-- App.vue -->
<template>
  <Icon />
</template>
<script>
import Icon from "./icon.svg";

export default {
  components: {
    Icon,
  },
};
</script>

If you want disabled this plugin for specific file, just add ?raw when you import.

import Icon from "./icon.svg?raw"; // svg file import without transform

Options

createSvgPlugin(option: {
  svgo?: boolean            // whether optimized by svgo
  svgoConfig?: SVGO.Options // check https://github.com/svg/svgo
  defaultImport?: 'url' | 'raw'
} = {});

License

MIT

Keywords

FAQs

Last updated on 13 Jul 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc