JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7644
  • Score
    100M100P100Q120435F
  • License MIT

Use svg as vue components with support for both vue2.7 and vue3.x

Package Exports

  • unplugin-svg-vue-component
  • unplugin-svg-vue-component/vite

Readme

unplugin-svg-vue-component

Use svg as vue components with support for both vue2.7 and vue3.x.

npm i unplugin-svg-vue-component

Usage

Vite

import svgPlugin from 'unplugin-svg-vue-component/vite'
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    vue(),
    svgPlugin(),
  ],
})
<script setup lang="ts">
import MsgIcon from './msg.svg'
</script>

<template>
  <MsgIcon />
</template>

Options

  • optimize: Disabled by default. Based on svgo
// https://github.com/svg/svgo
export default defineConfig({
  plugins: [
    vue2(),
    svgPlugin({ optimize: true }),
  ],
})

Acknowledgement

Inspired by the following projects

License

MIT